尚筹网16确认回报、订单

搭建order-consumer开发环境

参照project-consumer

注意不要忘了在zuul里面添加order-consumer对应的路由规则

crowd-order:
  service-id: adom-crowd-order
  path: /order/**

建模

结构

物理建模

订单表

CREATE TABLE `project_crowd`.`t_order` (
`id` INT NOT NULL AUTO_INCREMENT COMMENT '主键', 
`order_num` CHAR(100) COMMENT '订单号', 
`pay_order_num` CHAR(100) COMMENT '支付宝流水号',
 `order_amount` DOUBLE(10,5) COMMENT '订单金额', 
`invoice` INT COMMENT '是否开发票(0 不开,1 开)',
 `invoice_title` CHAR(100) COMMENT '发票抬头', 
`order_remark` CHAR(100) COMMENT '订单备注', 
`address_id` CHAR(100) COMMENT '收货地址 id', 
PRIMARY KEY (`id`)
);

收获地址表

CREATE TABLE `project_crowd`.`t_address` (
`id` INT NOT NULL AUTO_INCREMENT COMMENT '主键',
`receive_name` CHAR(100) COMMENT '收件人', 
`phone_num` CHAR(100) COMMENT '手机号', 
`address` CHAR(200) COMMENT '收货地址',
 `member_id` INT COMMENT '用户 id',
PRIMARY KEY (`id`) 
);

项目信息表

CREATE TABLE `project_crowd`.`t_order_project` (
`id` INT NOT NULL AUTO_INCREMENT COMMENT '主键', 
`project_name` CHAR(200) COMMENT '项目名称', 
`launch_name` CHAR(100) COMMENT '发起人',
 `return_content` CHAR(200) COMMENT '回报内容', 
`return_count` INT COMMENT '回报数量',
 `support_price` INT COMMENT '支持单价',
`freight` INT COMMENT '配送费用', 
`order_id` INT COMMENT '订单表的主键', 
PRIMARY KEY (`id`)
);

目标1:确认回报内容

思路

操作起点

<a th:href="'http://www.crowd.com/order/confirm/return/info/'+${return.returnId}" class="btn btn-warning btn-lg">支持</a>

注意1:因为需要从project-consumer跳转到order-consumer,所以要通过域名经过网关进行访问,以保证能够保持会话状态.

注意2:需要携带项目id和回报id便于查询数据

 

创建OrderProjectVO

public class OrderProjectVO implements Serializable {
    private static final long serialVersionUID = 1L;
    private Integer id;
    private String projectName;
    private String launchName;
    private String returnContent;
    private Integer returnCount;
    private Integer supportPrice;
    private Integer freight;
    private Integer orderId;
    private Integer signalPurchase;
    private Integer purchase;
    public OrderProjectVO() {
    }
    public OrderProjectVO(Integer id, String projectName, String launchName, String returnContent, Integer returnCount, Integer supportPrice, Integer freight, Integer orderId, Integer signalPurchase, Integer purchase) {
        this.id = id;
        this.projectName = projectName;
        this.launchName = launchName;
        this.returnContent = returnContent;
        this.returnCount = returnCount;
        this.supportPrice = supportPrice;
        this.freight = freight;
        this.orderId = orderId;
        this.signalPurchase = signalPurchase;
        this.purchase = purchase;
    }

调用接口

@RequestMapping("/confirm/return/info/{returnId}")
public String showReturnConfirmInfo(

        @PathVariable("returnId") Integer returnId,
        HttpSession session) {
    ResultEntity<OrderProjectVO> resultEntity =
            mySQLRemoteService.getOrderProjectVORemote(returnId);

    if (ResultEntity.SUCCESS.equals(resultEntity.getResult())) {
        OrderProjectVO orderProjectVO = resultEntity.getData();
        // 为了在后续操作中保持orderProjectVO数据,存入session
        session.setAttribute("orderProjectVO", orderProjectVO);

    }

    return "confirm_return";
}

Feign接口

@RequestMapping("/get/order/project/vo/remote")
ResultEntity<OrderProjectVO> getOrderProjectVORemote(@RequestParam("returnId") Integer returnId);

完成接口

orderProviderController

@RequestMapping("get/order/project/vo/remote")
ResultEntity<OrderProjectVO> getOrderProjectVORemote(

        @RequestParam("returnId") Integer returnId) {
    try {
        OrderProjectVO orderProjectVO = orderService.getOrderProjectVO(returnId);
        return ResultEntity.sucessWithData(orderProjectVO);
    } catch (Exception e) {
        e.printStackTrace();
        return ResultEntity.failed(e.getMessage());
    }

}

OrderServiceImpl

@Override
public OrderProjectVO getOrderProjectVO( Integer returnId) {
    return orderProjectPOMapper.selectOrderProjectVO(returnId);
}

SQL

<select id="selectOrderProjectVO" resultType="com.example.entity.vo.OrderProjectVO">
        SELECT DISTINCT
          project_name projectName,
          content returnContent,
          description_simple launchName,
          t_return.supportmoney supportPrice,
          freight freight,
          COUNT returnCount,
          signalpurchase signalPurchase,
          purchase purchase
          FROM
          t_project
          LEFT JOIN t_member_launch_info
            ON t_project.memberid = t_member_launch_info.memberid
          LEFT JOIN t_return
            ON t_project.id = t_return.projectid
          WHERE t_return.id = #{returnId}

</select>

完成页面显示

目标2:确认订单

思路

创建AddressVO

public class AddressVO implements Serializable {
    private static final long serialVersionUID = 1L;

    private Integer id;

    private String receiveName;

    private String phoneNum;

    private String address;

    private Integer memberId;

    public AddressVO() {
    }

    public AddressVO(Integer id, String receiveName, String phoneNum, String address, Integer memberId) {
        this.id = id;
        this.receiveName = receiveName;
        this.phoneNum = phoneNum;
        this.address = address;
        this.memberId = memberId;
    }

Session域合并回报数量

@RequestMapping("/confirm/order/{returnCount}")
public String showConfirmOderInfo(
        @PathVariable("returnCount") Integer returnCount,
        HttpSession session) {
    // 把回报数量传入session
    OrderProjectVO orderProjectVO = (OrderProjectVO) session.getAttribute("orderProjectVO");
    orderProjectVO.setReturnCount(returnCount);
    // 为了在后续操作中保持orderProjectVO数据,存入session
    session.setAttribute("orderProjectVO", orderProjectVO);
    // 获取已登录用户的id
    MemberLoginVO memberLoginVO = (MemberLoginVO) session.getAttribute(ConstantUtil.ATTR_NAME_LOGIN_MEMBER);
    Integer memberId = memberLoginVO.getId();
    // 查询目前的收获地址数据
    ResultEntity<List<AddressVO>> resultEntity = mySQLRemoteService.getAddressVORemote(memberId);
    if (ResultEntity.SUCCESS.equals(resultEntity.getResult())) {
        List<AddressVO> resultEntityData = resultEntity.getData();
        // 为了在后续操作中保持orderProjectVO数据,存入session
        session.setAttribute("addressVOList", resultEntityData);
    }
    return "confirm_order";
}

页面显示

新增收获地址

控制立即付款按钮是否有效

勾选我已了解风险和规则有效

$("#knowRoleCheckBox").click(function(){
   var currentStatus = this.checked;
   if(currentStatus) {
      $("#payButton").prop("disabled", "");
   }else{
      $("#payButton").prop("disabled","disabled");
   }
});

 

posted @ 2020-08-02 22:49  Adom_ye  阅读(60)  评论(0编辑  收藏