Browse Source

申请参会

huwhois 5 years ago
parent
commit
16cff78d6e
1 changed files with 55 additions and 39 deletions
  1. 55 39
      src/main/java/io/renren/modules/app/controller/OrderController.java

+ 55 - 39
src/main/java/io/renren/modules/app/controller/OrderController.java

@ -24,11 +24,7 @@ import io.renren.modules.app.annotation.LoginUser;
24 24
import io.renren.modules.app.entity.UserEntity;
25 25
import io.renren.modules.app.service.UserService;
26 26

27

28

29 27
/**
30
 * 
31
 *
32 28
 * @author chenshun
33 29
 * @email sunlightcs@gmail.com
34 30
 * @date 2020-02-21 15:10:27
@ -45,7 +41,6 @@ public class OrderController {
45 41
    @Autowired
46 42
    private PaymentService paymentService;
47 43
    
48
    
49 44
    /**
50 45
     * 订单列表
51 46
     */
@ -53,7 +48,7 @@ public class OrderController {
53 48
    @GetMapping("/list")
54 49
    public R orderList(@RequestAttribute("userId") Integer userId){
55 50
        System.out.println(userId);
56
        Long memberId = Long.valueOf(userId);        
51
        Long memberId = Long.valueOf(userId);
57 52

58 53
        List<Map<String, Object>> orderList = userService.queryOrderList(memberId);        
59 54

@ -66,19 +61,30 @@ public class OrderController {
66 61
    @Login
67 62
    @PostMapping("/save")
68 63
    public R save(@RequestBody Map<String, Object> params, @LoginUser UserEntity user){
69
        Long meetingId = Long.valueOf(params.get("meetingId").toString());
64
        Long meetingId = 0L;
65
        if (params.containsKey("meetingId")) {
66
            meetingId = Long.valueOf(params.get("meetingId").toString());
67
        } else {
68
            return R.error("会议id 不可为空");
69
        }
70 70
        AttendersEntity attendersEntity = new AttendersEntity();
71 71
        attendersEntity.setMeetingId(meetingId);
72 72
        attendersEntity.setMemberId(user.getUserId());
73 73
        attendersEntity.setName(user.getUsername());
74 74
        attendersEntity.setPhone(user.getPhone());
75 75
        attendersEntity.setEmail(user.getEmail());
76
        attendersEntity.setTypeId(Long.valueOf(params.get("typeId").toString()));
77
        attendersEntity.setRoom(Integer.valueOf(params.get("room").toString()));
78
        attendersEntity.setTransfer(Integer.valueOf(params.get("transfer").toString()));
76
        Long typeId = params.containsKey("typeId") ? Long.valueOf(params.get("typeId").toString()) : 0L ;
77
        attendersEntity.setTypeId(typeId);
78
        Integer room = params.containsKey("room") ? Integer.valueOf(params.get("room").toString()) : 0 ;
79
        attendersEntity.setRoom(room);
80
        Integer transfer = params.containsKey("transfer") ? Integer.valueOf(params.get("transfer").toString()) : 0 ;
81
        attendersEntity.setTransfer(transfer);
79 82
        attendersEntity.setCreateTime(new Date());
80 83
        
81
        attendersService.save(attendersEntity);
84
        boolean res = attendersService.save(attendersEntity);
85
        if (!res) {
86
            return R.error("未知错误");
87
        }
82 88
        // System.out.println(attendersEntity.getId());
83 89

84 90
        // 付款信息
@ -92,38 +98,48 @@ public class OrderController {
92 98
        paymentEntity.setMeetingId(meetingId);
93 99
        paymentEntity.setAttendersId(attendersEntity.getId());
94 100
        paymentEntity.setPayType(1);
95
        paymentEntity.setTaxTitle(params.get("taxTitle").toString());
96
        paymentEntity.setTaxNumber(params.get("taxNumber").toString());
97
        paymentEntity.setAddrPhone(params.get("addPhone").toString());
98
        paymentEntity.setBankAddrAccount(params.get("bankAddrAccount").toString());
99
        paymentEntity.setTaxAddress(params.get("taxAddress").toString());
101
        String taxTitle = params.containsKey("taxTitle") ? params.get("taxTitle").toString() : "";
102
        paymentEntity.setTaxTitle(taxTitle);
103
        String taxNumber = params.containsKey("taxNumber") ? params.get("taxNumber").toString() : "";
104
        paymentEntity.setTaxNumber(taxNumber);
105
        String addPhone = params.containsKey("addPhone") ? params.get("addPhone").toString() : "";
106
        paymentEntity.setAddrPhone(addPhone);
107
        String bankAddrAccount = params.containsKey("bankAddrAccount") ? params.get("bankAddrAccount").toString() : "";
108
        paymentEntity.setBankAddrAccount(bankAddrAccount);
109
        String taxAddress = params.containsKey("taxAddress") ? params.get("taxAddress").toString() : "";
110
        paymentEntity.setTaxAddress(taxAddress);
100 111
        paymentEntity.setCreateTime(new Date());
101 112

102
        paymentService.save(paymentEntity);
103

104
        return R.ok();
105
    }
106

107
    /**
108
     * 修改
109
     */
110
    @Login
111
    @PostMapping("/update")
112
    public R update(@RequestBody AttendersEntity attenders){
113
		attendersService.updateById(attenders);
114

115
        return R.ok();
116
    }
117

118
    /**
119
     * 删除
120
     */
121
    @Login
122
    @PostMapping("/delete")
123
    public R delete(@RequestBody Long[] ids){
124
		attendersService.removeByIds(Arrays.asList(ids));
113
        try {
114
            paymentService.save(paymentEntity);
115
        } catch (Exception e) {
116
            attendersService.removeById(attendersEntity.getId());
117
            e.printStackTrace();
118
            return R.error("订单生成出错");
119
        }
125 120

126 121
        return R.ok();
127 122
    }
128 123

124
    // /**
125
    //  * 修改
126
    //  */
127
    // @Login
128
    // @PostMapping("/update")
129
    // public R update(@RequestBody AttendersEntity attenders){
130
	// 	attendersService.updateById(attenders);
131

132
    //     return R.ok();
133
    // }
134

135
    // /**
136
    //  * 删除
137
    //  */
138
    // @Login
139
    // @PostMapping("/delete")
140
    // public R delete(@RequestBody Long[] ids){
141
	// 	attendersService.removeByIds(Arrays.asList(ids));
142

143
    //     return R.ok();
144
    // }
129 145
}