|
@@ -94,25 +94,39 @@ public class WxController extends BaseController {
|
|
|
*/
|
|
|
@PostMapping(value = "/appPrepareOrder")
|
|
|
@ApiOperation("app端微信支付下单")
|
|
|
- public Response<WxParamEntity> appPrepareOrder(@RequestParam @ApiParam(name="dictCode",value="字典编码")Long dictCode) throws Exception{
|
|
|
- //创建本地微信订单
|
|
|
- WxOrder order = new WxOrder();
|
|
|
- UserInfo student = SecurityUtils.getLoginUser().getStudent();
|
|
|
- String orderCode = getOrderCode(student.getId());
|
|
|
- order.setOutTradeNo(orderCode);
|
|
|
- order.setAppOpenid(student.getAppOpenid());
|
|
|
- order.setUnionId(student.getUnionId());
|
|
|
-
|
|
|
- SysDictData sysDictData = dictDataService.selectDictDataById(dictCode);
|
|
|
- String[] values = sysDictData.getDictValue().split(",");
|
|
|
- Double price = Double.parseDouble(values[0])*100; //订单总额
|
|
|
- int b = new Double(price).intValue();
|
|
|
- order.setTotal(b);
|
|
|
- order.setOrderStatus(OrderStatusEnum.PROCESSING.getCode());
|
|
|
-
|
|
|
-
|
|
|
- wxOrderService.save(order);
|
|
|
- return Response.success(placeAppWxOrder(order, order.getGoodsName()));
|
|
|
+ public Response<WxParamEntity> appPrepareOrder(@RequestBody WxOrderDTO wxOrderDTO) throws Exception{
|
|
|
+
|
|
|
+ UserInfo userInfo = SecurityUtils.getLoginUser().getStudent();
|
|
|
+ if(wxOrderDTO.getGoodsType()==1) {
|
|
|
+ int count = vipUserExamService.getUserExamByUnionIdAndGoodsId(userInfo.getUnionId(), wxOrderDTO.getGoodsId());
|
|
|
+ if (count > 0) {
|
|
|
+ throw new CustomException("您已购买过该考场,退回上个页面,重新进入。");
|
|
|
+ }
|
|
|
+ ExamInfo examInfo = examInfoService.getById(wxOrderDTO.getGoodsId());
|
|
|
+ //创建本地微信订单
|
|
|
+ WxOrder order = new WxOrder();
|
|
|
+ String orderCode = getOrderCode(userInfo.getId());
|
|
|
+ order.setGoodsId(wxOrderDTO.getGoodsId());
|
|
|
+ order.setGoodsName(examInfo.getName());
|
|
|
+ order.setGoodsType(1);
|
|
|
+ order.setOutTradeNo(orderCode);
|
|
|
+ order.setUserId(userInfo.getId());
|
|
|
+ order.setXcxOpenid(userInfo.getXcxOpenid());
|
|
|
+ order.setAppOpenid(userInfo.getAppOpenid());
|
|
|
+ order.setGzhOpenid(userInfo.getGzhOpenid());
|
|
|
+ order.setUnionId(userInfo.getUnionId());
|
|
|
+ order.setPhoneType(wxOrderDTO.getPhoneType()); //手机类型 1:苹果 2:安卓
|
|
|
+ order.setForeType(wxOrderDTO.getForeType()); //前端类型 1:app 2:小程序 3:公众号
|
|
|
+ order.setTotal(examInfo.getPrice());
|
|
|
+ order.setOrderStatus(OrderStatusEnum.PROCESSING.getCode());
|
|
|
+ wxOrderService.save(order);
|
|
|
+ return Response.success(placeAppWxOrder(order, examInfo.getName()));
|
|
|
+ } else if (wxOrderDTO.getGoodsType()==2) {
|
|
|
+ throw new CustomException("请正确传入GoodsType,GoodsType=2未开发");
|
|
|
+ } else {
|
|
|
+ throw new CustomException("请正确传入GoodsType。");
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|