|
|
@@ -1,11 +1,15 @@
|
|
|
package com.fs.app.controller.live;
|
|
|
|
|
|
+import cn.binarywang.wx.miniapp.api.WxMaService;
|
|
|
+import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
|
|
+import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.TypeReference;
|
|
|
import com.fs.app.annotation.Login;
|
|
|
import com.fs.app.controller.AppBaseController;
|
|
|
-import com.fs.app.param.FsStoreOrderExpressParam;
|
|
|
import com.fs.app.utils.JwtUtils;
|
|
|
import com.fs.common.annotation.Log;
|
|
|
import com.fs.common.annotation.RepeatSubmit;
|
|
|
@@ -13,29 +17,67 @@ import com.fs.common.core.domain.AjaxResult;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.enums.BusinessType;
|
|
|
import com.fs.common.exception.CustomException;
|
|
|
+import com.fs.common.utils.IpUtil;
|
|
|
+import com.fs.common.utils.ParseUtils;
|
|
|
import com.fs.common.utils.ServletUtils;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
|
+import com.fs.common.utils.ip.IpUtils;
|
|
|
import com.fs.common.utils.poi.ExcelUtil;
|
|
|
+import com.fs.core.config.WxMaConfiguration;
|
|
|
+import com.fs.erp.service.IErpOrderService;
|
|
|
import com.fs.his.dto.ExpressInfoDTO;
|
|
|
import com.fs.his.enums.ShipperCodeEnum;
|
|
|
import com.fs.his.service.IFsExpressService;
|
|
|
+import com.fs.his.utils.ConfigUtil;
|
|
|
+import com.fs.hisStore.domain.*;
|
|
|
+import com.fs.hisStore.dto.FsStoreOrderComputeDTO;
|
|
|
+import com.fs.hisStore.enums.OrderInfoEnum;
|
|
|
+import com.fs.hisStore.mapper.FsStorePaymentScrmMapper;
|
|
|
+import com.fs.hisStore.param.*;
|
|
|
+import com.fs.hisStore.service.IFsUserScrmService;
|
|
|
+import com.fs.hisStore.vo.FsStoreOrderItemVO;
|
|
|
+import com.fs.huifuPay.domain.HuiFuCreateOrder;
|
|
|
+import com.fs.huifuPay.domain.HuifuCreateOrderResult;
|
|
|
+import com.fs.huifuPay.service.HuiFuService;
|
|
|
import com.fs.live.domain.LiveOrder;
|
|
|
+import com.fs.live.domain.LiveOrderPayment;
|
|
|
import com.fs.live.dto.LiveOrderComputeDTO;
|
|
|
import com.fs.live.enums.LiveOrderCancleReason;
|
|
|
+import com.fs.live.mapper.LiveOrderPaymentMapper;
|
|
|
import com.fs.live.param.*;
|
|
|
+import com.fs.live.service.ILiveAfterSalesService;
|
|
|
+import com.fs.live.service.ILiveOrderItemService;
|
|
|
import com.fs.live.service.ILiveOrderService;
|
|
|
+import com.fs.live.vo.FsMyLiveOrderListQueryVO;
|
|
|
+import com.fs.live.vo.LiveOrderItemListUVO;
|
|
|
import com.fs.live.vo.LiveOrderListVo;
|
|
|
+import com.fs.pay.pay.dto.OrderQueryDTO;
|
|
|
+import com.fs.pay.service.IPayService;
|
|
|
+import com.fs.store.config.StoreConfig;
|
|
|
+import com.fs.system.service.ISysConfigService;
|
|
|
+import com.fs.wx.miniapp.config.WxMaProperties;
|
|
|
+import com.fs.ybPay.domain.OrderResult;
|
|
|
+import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
|
|
+import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
|
|
+import com.github.binarywang.wxpay.config.WxPayConfig;
|
|
|
+import com.github.binarywang.wxpay.exception.WxPayException;
|
|
|
+import com.github.binarywang.wxpay.service.WxPayService;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import me.chanjar.weixin.common.error.WxErrorException;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/**
|
|
|
* 订单Controller
|
|
|
@@ -49,281 +91,769 @@ import java.util.Map;
|
|
|
public class LiveOrderController extends AppBaseController
|
|
|
{
|
|
|
@Autowired
|
|
|
- private ILiveOrderService liveOrderService;
|
|
|
+ private ILiveOrderService orderService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ILiveOrderItemService liveOrderItemService;
|
|
|
|
|
|
@Autowired
|
|
|
- private IFsExpressService expressService;
|
|
|
+ private WxMaProperties properties;
|
|
|
+
|
|
|
@Autowired
|
|
|
- private JwtUtils jwtUtils;
|
|
|
+ private WxPayService wxPayService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private LiveOrderPaymentMapper liveOrderPaymentMapper;
|
|
|
|
|
|
- @Login
|
|
|
- @ApiOperation("物流查询多运单号")
|
|
|
- @PostMapping("/getExpressMulti")
|
|
|
- public R getExpressMulti( @Validated @RequestBody FsStoreOrderExpressParam param){
|
|
|
- log.info("物流查询多运单号 请求参数: {}", JSON.toJSONString(param));
|
|
|
+ @Autowired
|
|
|
+ private ISysConfigService configService;
|
|
|
|
|
|
- LiveOrder order=liveOrderService.selectLiveOrderByOrderId(String.valueOf(param.getOrderId()));
|
|
|
- if (ObjectUtil.isNull(order)) {
|
|
|
- throw new CustomException("订单不存在");
|
|
|
- }
|
|
|
-// if (order.getStatus() < 2) {
|
|
|
-// throw new CustomException("未发货订单不能查询");
|
|
|
-// }
|
|
|
- return liveOrderService.getExpressMulti(order);
|
|
|
- }
|
|
|
+ @Autowired
|
|
|
+ private IFsUserScrmService userService;
|
|
|
|
|
|
- @Login
|
|
|
- @ApiOperation("物流查询")
|
|
|
- @PostMapping("/getExpress")
|
|
|
- public R getExpress( @Validated @RequestBody FsStoreOrderExpressParam param){
|
|
|
- log.info("物流查询 参数: {}", JSON.toJSONString(param));
|
|
|
+ @Autowired
|
|
|
+ private ILiveAfterSalesService liveAfterSalesService;
|
|
|
+ @Autowired
|
|
|
+ IPayService ybPayService;
|
|
|
+ @Autowired
|
|
|
+ private HuiFuService huiFuService;
|
|
|
|
|
|
- LiveOrder order=liveOrderService.selectLiveOrderByOrderId(String.valueOf(param.getOrderId()));
|
|
|
- if (ObjectUtil.isNull(order)) {
|
|
|
- throw new CustomException("订单不存在");
|
|
|
- }
|
|
|
- if (order.getStatus() <2) {
|
|
|
- throw new CustomException("未发货订单不能查询");
|
|
|
- }
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("erpOrderServiceImpl")
|
|
|
+ private IErpOrderService gyOrderService;
|
|
|
|
|
|
- return liveOrderService.getExpress(order);
|
|
|
- }
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("wdtErpOrderServiceImpl")
|
|
|
+ private IErpOrderService wdtOrderService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("k9OrderScrmServiceImpl")
|
|
|
+ private IErpOrderService k9OrderService;
|
|
|
|
|
|
- /**
|
|
|
- * 查询订单列表
|
|
|
- */
|
|
|
- @Login
|
|
|
- @GetMapping("/list")
|
|
|
- public R list(LiveOrder liveOrder)
|
|
|
- {
|
|
|
- log.info("查询订单列表 参数: {}", JSON.toJSONString(liveOrder));
|
|
|
+ @Autowired
|
|
|
+ private ConfigUtil configUtil;
|
|
|
|
|
|
- PageHelper.startPage(Integer.parseInt(ServletUtils.getParameter("pageNum")) ,Integer.parseInt(ServletUtils.getParameter("pageSize")) );
|
|
|
- try {
|
|
|
- liveOrder.setUserId(getUserId());
|
|
|
- List<LiveOrderListVo> list = liveOrderService.selectLiveOrderListVo(liveOrder);
|
|
|
- PageInfo<LiveOrderListVo> result = new PageInfo<>(list);
|
|
|
- return R.ok().put("data", result);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("查询失败!",e);
|
|
|
- return R.error("操作异常");
|
|
|
- }
|
|
|
|
|
|
- }
|
|
|
+ @Autowired
|
|
|
+ private IFsExpressService expressService;
|
|
|
+ @Autowired
|
|
|
+ private JwtUtils jwtUtils;
|
|
|
|
|
|
- /**
|
|
|
- * 导出订单列表
|
|
|
- */
|
|
|
- @Log(title = "订单", businessType = BusinessType.EXPORT)
|
|
|
- @GetMapping("/export")
|
|
|
- public AjaxResult export(LiveOrder liveOrder)
|
|
|
- {
|
|
|
- log.info("订单导出 参数: {}", JSON.toJSONString(liveOrder));
|
|
|
|
|
|
- List<LiveOrder> list = liveOrderService.selectLiveOrderList(liveOrder);
|
|
|
- ExcelUtil<LiveOrder> util = new ExcelUtil<LiveOrder>(LiveOrder.class);
|
|
|
- return util.exportExcel(list, "订单数据");
|
|
|
+ @Login
|
|
|
+ @ApiOperation("获取我的订单列表")
|
|
|
+ @GetMapping("/getMyStoreOrderList")
|
|
|
+ public R getMyStoreOrderList(FsMyLiveOrderQueryParam param, HttpServletRequest request){
|
|
|
+ PageHelper.startPage(param.getPage(), param.getPageSize());
|
|
|
+ param.setUserId(Long.parseLong(getUserId()));
|
|
|
+ List<FsMyLiveOrderListQueryVO> list=orderService.selectFsMyLiveOrderListVO(param);
|
|
|
+ PageInfo<FsMyLiveOrderListQueryVO> listPageInfo=new PageInfo<>(list);
|
|
|
+ return R.ok().put("data",listPageInfo);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 获取订单详细信息
|
|
|
- */
|
|
|
@Login
|
|
|
- @GetMapping(value = "/info/{orderId}")
|
|
|
- public AjaxResult getInfo(@PathVariable("orderId") String orderId)
|
|
|
- {
|
|
|
- log.info("获取订单详细信息 参数: {}",orderId);
|
|
|
-
|
|
|
- return AjaxResult.success(liveOrderService.selectLiveOrderByOrderId(orderId));
|
|
|
+ @ApiOperation("获取销售公司订单列表")
|
|
|
+ @GetMapping("/getCompanyStoreOrderList")
|
|
|
+ public R getCompanyStoreOrderList(FsMyLiveOrderQueryParam param, HttpServletRequest request){
|
|
|
+ PageHelper.startPage(param.getPage(), param.getPageSize());
|
|
|
+ List<FsMyLiveOrderListQueryVO> list=orderService.selectFsCompanyLiveOrderListVO(param);
|
|
|
+ PageInfo<FsMyLiveOrderListQueryVO> listPageInfo=new PageInfo<>(list);
|
|
|
+ return R.ok().put("data",listPageInfo);
|
|
|
}
|
|
|
|
|
|
- @ApiOperation("确认订单")
|
|
|
- @PostMapping("/confirm")
|
|
|
- public R confirm(@Validated @RequestBody LiveOrderConfirmParam param, HttpServletRequest request){
|
|
|
- log.info("确认订单 参数: {}", JSON.toJSONString(param));
|
|
|
-
|
|
|
- param.setUserId(Long.parseLong(getUserId()));
|
|
|
- return liveOrderService.confirmOrder(param);
|
|
|
+ @Login
|
|
|
+ @ApiOperation("获取我的订单详情")
|
|
|
+ @GetMapping("/getMyStoreOrderById")
|
|
|
+ public R getMyStoreOrderById(@RequestParam("orderId") Long orderId, HttpServletRequest request){
|
|
|
+ LiveOrder order=orderService.selectLiveOrderByOrderId(String.valueOf(orderId));
|
|
|
+ order.setUserPhone(ParseUtils.parsePhone(order.getUserPhone()));
|
|
|
+ order.setUserAddress(ParseUtils.parseIdCard(order.getUserAddress()));
|
|
|
+ List<LiveOrderItemListUVO> list = liveOrderItemService.selectLiveOrderItemListUVOByOrderId(orderId);
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(order.getCreateTime());
|
|
|
+ String json=configService.selectConfigByKey("his.store");
|
|
|
+ StoreConfig config= JSONUtil.toBean(json,StoreConfig.class);
|
|
|
+ calendar.add(Calendar.MINUTE,config.getUnPayTime());
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String payLimitTime = format.format(calendar.getTime() );
|
|
|
+ //处理是否可以申请售后
|
|
|
+ Integer isAfterSales=0;
|
|
|
+ if(order.getStatus().equals(OrderInfoEnum.STATUS_3.getValue())) {
|
|
|
+ //已完成订单
|
|
|
+ isAfterSales=1;
|
|
|
+ if (order.getFinishTime() != null) {
|
|
|
+ if (config.getStoreAfterSalesDay() != null && config.getStoreAfterSalesDay() > 0) {
|
|
|
+ //判断完成时间是否超过指定时间
|
|
|
+ Calendar calendarAfterSales = new GregorianCalendar();
|
|
|
+ calendarAfterSales.setTime(order.getFinishTime());
|
|
|
+ calendarAfterSales.add(calendarAfterSales.DATE, config.getStoreAfterSalesDay()); //把日期往后增加一天,整数 往后推,负数往前移动
|
|
|
+ if (calendarAfterSales.getTime().getTime() < new Date().getTime()) {
|
|
|
+ isAfterSales = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(order.getStatus()==1||order.getStatus()==2){
|
|
|
+ isAfterSales=1;
|
|
|
+ }
|
|
|
+ return R.ok().put("isAfterSales",isAfterSales).put("order",order).put("items",list).put("payLimitTime",payLimitTime);
|
|
|
}
|
|
|
|
|
|
- @PostMapping("/buy")
|
|
|
- @ApiOperation("购物车购买")
|
|
|
@Login
|
|
|
- @RepeatSubmit
|
|
|
- public R buy(@RequestBody LiveOrder liveOrder)
|
|
|
- {
|
|
|
- log.info("购物车购买 参数: {}", JSON.toJSONString(liveOrder));
|
|
|
-
|
|
|
- liveOrder.setUserId(getUserId());
|
|
|
- return liveOrderService.buy(liveOrder);
|
|
|
+ @ApiOperation("获取订单")
|
|
|
+ @GetMapping("/getStoreOrderById")
|
|
|
+ public R getStoreOrderById(@RequestParam("orderId") Long orderId, HttpServletRequest request){
|
|
|
+ LiveOrder order=orderService.selectLiveOrderByOrderId(String.valueOf(orderId));
|
|
|
+
|
|
|
+ order.setUserPhone(ParseUtils.parsePhone(order.getUserPhone()));
|
|
|
+ order.setUserAddress(ParseUtils.parseIdCard(order.getUserAddress()));
|
|
|
+
|
|
|
+ String json=configService.selectConfigByKey("his.store");
|
|
|
+ StoreConfig config=JSONUtil.toBean(json,StoreConfig.class);
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(order.getCreateTime());
|
|
|
+ calendar.add(Calendar.MINUTE,config.getUnPayTime());
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String payLimitTime = format.format(calendar.getTime() );
|
|
|
+ return R.ok().put("order",order).put("payLimitTime",payLimitTime);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 新增订单
|
|
|
- */
|
|
|
- @Login
|
|
|
- @Log(title = "订单", businessType = BusinessType.INSERT)
|
|
|
- @PostMapping("/create")
|
|
|
- @RepeatSubmit
|
|
|
- public R add(@RequestBody LiveOrder liveOrder)
|
|
|
- {
|
|
|
- log.info("新增订单: {}", JSON.toJSONString(liveOrder));
|
|
|
|
|
|
- liveOrder.setUserId(getUserId());
|
|
|
- return liveOrderService.createLiveOrder(liveOrder);
|
|
|
+ @Login
|
|
|
+ @ApiOperation("确认订单")
|
|
|
+ @PostMapping("/confirm")
|
|
|
+ public R confirm(@Validated @RequestBody LiveOrderConfirmParam param, HttpServletRequest request){
|
|
|
+ param.setUserId(Long.valueOf(getUserId()));
|
|
|
+ return orderService.confirmOrder(param);
|
|
|
}
|
|
|
-
|
|
|
@Login
|
|
|
@ApiOperation("计算订单金额")
|
|
|
@PostMapping("/computed")
|
|
|
- public R computed(@Validated @RequestBody LiveOrderComputedParam param){
|
|
|
- log.info("计算订单金额 {}",JSON.toJSONString(param));
|
|
|
-
|
|
|
- LiveOrderComputeDTO dto=liveOrderService.computedOrder(Long.parseLong(getUserId()),param);
|
|
|
+ public R computed(@Validated @RequestBody LiveOrderComputedParam param, HttpServletRequest request){
|
|
|
+ LiveOrderComputeDTO dto=orderService.computedOrder(Long.parseLong(getUserId()),param);
|
|
|
return R.ok().put("data",dto);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 修改订单
|
|
|
- */
|
|
|
@Login
|
|
|
- @Log(title = "订单", businessType = BusinessType.UPDATE)
|
|
|
- @PutMapping("/update")
|
|
|
- @RepeatSubmit
|
|
|
- public R edit(@RequestBody LiveOrder liveOrder)
|
|
|
- {
|
|
|
- return R.ok().put("orderId",liveOrder.getOrderId());
|
|
|
+ @ApiOperation("创建订单")
|
|
|
+ @PostMapping("/create")
|
|
|
+ public R create(@Validated @RequestBody LiveOrder param, HttpServletRequest request){
|
|
|
+ String userId= getUserId();
|
|
|
+ log.info("开始创建订单,登录用户id:{}", userId);
|
|
|
+ return orderService.createLiveOrder(param);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- /**
|
|
|
- * 查看物流状态
|
|
|
- * */
|
|
|
- @GetMapping(value = "/getExpress/{id}")
|
|
|
- @Deprecated
|
|
|
- public R getExpress(@PathVariable("id") Long id)
|
|
|
+ @Login
|
|
|
+ @ApiOperation("支付")
|
|
|
+ @PostMapping("/pay")
|
|
|
+ @Transactional
|
|
|
+ //@Synchronized
|
|
|
+ public R pay(HttpServletRequest request, @Validated @RequestBody LiveOrderPayParam param)
|
|
|
{
|
|
|
- log.info("查看物流状态 {}",id);
|
|
|
+ LiveOrder order=orderService.selectLiveOrderByOrderId(String.valueOf(param.getOrderId()));
|
|
|
+ if(order==null){
|
|
|
+ return R.error("订单不存在");
|
|
|
+ }
|
|
|
+ if(order.getStatus()!= OrderInfoEnum.STATUS_0.getValue()){
|
|
|
+ return R.error("订单状态不正确");
|
|
|
+ }
|
|
|
+ String orderId=redisCache.getCacheObject("isPaying:"+order.getOrderId());
|
|
|
+ if(StringUtils.isNotEmpty(orderId)&&orderId.equals(order.getOrderId().toString())){
|
|
|
+ return R.error("正在支付中...");
|
|
|
+ }
|
|
|
|
|
|
- LiveOrder order=liveOrderService.selectLiveOrderByOrderId(String.valueOf(id));
|
|
|
- ExpressInfoDTO expressInfoDTO=null;
|
|
|
- if(StringUtils.isNotEmpty(order.getDeliverySn())){
|
|
|
+ FsUserScrm user=userService.selectFsUserById(Long.valueOf(order.getUserId()));
|
|
|
+ if(user!=null&& StringUtils.isNotEmpty(user.getMaOpenId())){
|
|
|
+ //已改价处理
|
|
|
+ if(order.getIsEditMoney()!=null&&order.getIsEditMoney()==1){
|
|
|
+ //改过价不做处理
|
|
|
|
|
|
- String lastFourNumber = "";
|
|
|
- if (order.getDeliverySn().equals(ShipperCodeEnum.SF.getValue())) {
|
|
|
- lastFourNumber = order.getUserPhone();
|
|
|
- if (lastFourNumber.length() == 11) {
|
|
|
- lastFourNumber = StrUtil.sub(lastFourNumber, lastFourNumber.length(), -4);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ String config=configService.selectConfigByKey("his.store");
|
|
|
+ StoreConfig storeConfig= JSONUtil.toBean(config,StoreConfig.class);
|
|
|
+ if(param.getPayType().equals(1)){
|
|
|
+ order.setPayType("1");
|
|
|
+ order.setPayMoney(order.getPayPrice());
|
|
|
+ order.setPayDelivery(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ else if(param.getPayType().equals(2)){
|
|
|
+ order.setPayType("2");
|
|
|
+ BigDecimal payMoney=order.getPayPrice().multiply(new BigDecimal(storeConfig.getPayRate())).divide(new BigDecimal(100));
|
|
|
+ payMoney=new BigDecimal(payMoney.setScale(0, BigDecimal.ROUND_HALF_UP).longValue());
|
|
|
+ order.setPayDelivery(order.getPayPrice().subtract(payMoney));
|
|
|
+ order.setPayMoney(payMoney);
|
|
|
+ }
|
|
|
+ else if(param.getPayType().equals(3)){
|
|
|
+ //货到付款
|
|
|
+ order.setPayType("3");
|
|
|
+ BigDecimal amount=redisCache.getCacheObject("orderAmount:"+order.getOrderId());
|
|
|
+ BigDecimal payMoney = BigDecimal.ZERO;
|
|
|
+ if (amount != null){
|
|
|
+ payMoney=amount;
|
|
|
+ }
|
|
|
+ order.setPayMoney(payMoney);
|
|
|
+ order.setPayDelivery(order.getPayPrice().subtract(payMoney) );
|
|
|
+// order.setPayMoney(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ orderService.updateLiveOrder(order);
|
|
|
+ }
|
|
|
+ String payCode = IdUtil.getSnowflake(0, 0).nextIdStr();
|
|
|
+// order.setOrderCode(orderCode);
|
|
|
+// if(order.getPayType().equals("1")||order.getPayType().equals("2")){
|
|
|
+ if((order.getPayType().equals("1")||order.getPayType().equals("2")||order.getPayType().equals("3")) && order.getPayMoney().compareTo(new BigDecimal(0))>0){
|
|
|
+ String json = configService.selectConfigByKey("his.pay");
|
|
|
+ FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
|
|
|
+ LiveOrderPayment storePayment=new LiveOrderPayment();
|
|
|
+ storePayment.setCompanyId(order.getCompanyId());
|
|
|
+ storePayment.setCompanyUserId(order.getCompanyUserId());
|
|
|
+ storePayment.setPayMode(fsPayConfig.getType());
|
|
|
+ storePayment.setStatus(0);
|
|
|
+ storePayment.setPayCode(payCode);
|
|
|
+ storePayment.setPayMoney(order.getPayMoney());
|
|
|
+ storePayment.setCreateTime(new Date());
|
|
|
+ storePayment.setPayTypeCode("weixin");
|
|
|
+ storePayment.setBusinessType(2);
|
|
|
+ storePayment.setRemark("直播订单支付");
|
|
|
+ storePayment.setOpenId(user.getRealName());
|
|
|
+ storePayment.setUserId(user.getUserId());
|
|
|
+ storePayment.setBusinessId(String.valueOf(order.getOrderId()));
|
|
|
+ liveOrderPaymentMapper.insertLiveOrderPayment(storePayment);
|
|
|
+
|
|
|
+ if (fsPayConfig.getType().equals("hf")){
|
|
|
+ HuiFuCreateOrder o = new HuiFuCreateOrder();
|
|
|
+ o.setTradeType("T_MINIAPP");
|
|
|
+ o.setOpenid(user.getMaOpenId());
|
|
|
+ o.setReqSeqId("live-"+storePayment.getPayCode());
|
|
|
+ o.setTransAmt(storePayment.getPayMoney().toString());
|
|
|
+ o.setGoodsDesc("直播订单支付");
|
|
|
+ if (param != null && StringUtils.isNotBlank(param.getAppId())) {
|
|
|
+ o.setAppId(param.getAppId());
|
|
|
+ }
|
|
|
+ HuifuCreateOrderResult result = huiFuService.createOrder(o);
|
|
|
+ if(result.getResp_code()!=null&&(result.getResp_code().equals("00000000")||result.getResp_code().equals("00000100"))){
|
|
|
+ LiveOrderPayment mt=new LiveOrderPayment();
|
|
|
+ mt.setPaymentId(storePayment.getPaymentId());
|
|
|
+ mt.setTradeNo(result.getHf_seq_id());
|
|
|
+ liveOrderPaymentMapper.updateLiveOrderPayment(mt);
|
|
|
+ redisCache.setCacheObject("isPaying:"+order.getOrderId(),order.getOrderId().toString(),1, TimeUnit.MINUTES);
|
|
|
+ Map<String, Object> resultMap = JSON.parseObject(result.getPay_info(), new TypeReference<Map<String, Object>>() {});
|
|
|
+ String s = (String) resultMap.get("package");
|
|
|
+ resultMap.put("packageValue",s);
|
|
|
+ return R.ok().put("payType",param.getPayType()).put("result",resultMap);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ return R.error(result.getResp_desc());
|
|
|
+ }
|
|
|
+ }else if (fsPayConfig.getType().equals("wx")){
|
|
|
+ WxPayConfig payConfig = new WxPayConfig();
|
|
|
+ payConfig.setAppId(fsPayConfig.getAppId());
|
|
|
+ payConfig.setMchId(fsPayConfig.getWxMchId());
|
|
|
+ payConfig.setMchKey(fsPayConfig.getWxMchKey());
|
|
|
+ payConfig.setSubAppId(org.apache.commons.lang3.StringUtils.trimToNull(null));
|
|
|
+ payConfig.setSubMchId(org.apache.commons.lang3.StringUtils.trimToNull(null));
|
|
|
+ payConfig.setKeyPath(fsPayConfig.getKeyPath());
|
|
|
+ payConfig.setNotifyUrl(fsPayConfig.getNotifyUrlScrm());
|
|
|
+ wxPayService.setConfig(payConfig);
|
|
|
+ WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
|
|
|
+ orderRequest.setOpenid(user.getMaOpenId());//公众号支付提供用户openid
|
|
|
+ orderRequest.setBody("直播订单支付");
|
|
|
+ orderRequest.setOutTradeNo("live-" + storePayment.getPayCode());
|
|
|
+ orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(storePayment.getPayMoney().toString()));//测试
|
|
|
+ //orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(money));//测试
|
|
|
+ orderRequest.setTradeType("JSAPI");
|
|
|
+ orderRequest.setSpbillCreateIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
|
|
|
+ //调用统一下单接口,获取"预支付交易会话标识"
|
|
|
+ try {
|
|
|
+ WxPayMpOrderResult orderResult = wxPayService.createOrder(orderRequest);
|
|
|
+ return R.ok().put("result", orderResult).put("type", "wx").put("isPay", 0).put("payType",param.getPayType());
|
|
|
+ } catch (WxPayException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ throw new CustomException("支付失败" + e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- expressInfoDTO=expressService.getExpressInfo(order.getOrderCode(),order.getDeliverySn(),order.getDeliverySn(),lastFourNumber);
|
|
|
+// else if(order.getPayType().equals("3")){
|
|
|
+ else if(order.getPayType().equals("3") && order.getPayMoney().compareTo(new BigDecimal(0))<=0){
|
|
|
+ //货到付款
|
|
|
+ orderService.payConfirm(2,order.getOrderId(),null,null,null,null);
|
|
|
+ return R.ok().put("payType",param.getPayType());
|
|
|
+ }
|
|
|
+ return R.error();
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ return R.error("用户OPENID不存在");
|
|
|
}
|
|
|
- return R.ok().put("data",expressInfoDTO);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 支付订单
|
|
|
- * */
|
|
|
- @PostMapping(value = "/pay")
|
|
|
- public void pay(LiveOrder liveOrder)
|
|
|
- {
|
|
|
- log.info("支付订单 参数: {}",liveOrder);
|
|
|
|
|
|
- liveOrderService.handlePay(liveOrder);
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
@Login
|
|
|
- @ApiOperation("支付宝支付")
|
|
|
- @PostMapping("/aliPayment")
|
|
|
- @RepeatSubmit
|
|
|
- public R aliPayment(@Validated @RequestBody FsUserLiveOrderPayUParam param)
|
|
|
- {
|
|
|
- param.setUserId(Long.parseLong(getUserId()));
|
|
|
- return R.ok();
|
|
|
+ @ApiOperation("修改支付类型")
|
|
|
+ @PostMapping("/editPayType")
|
|
|
+ @Transactional
|
|
|
+ public R editPayType(HttpServletRequest request, @Validated @RequestBody FsStoreOrderPayParam param) {
|
|
|
+ LiveOrder order=orderService.selectLiveOrderByOrderId(String.valueOf(param.getOrderId()));
|
|
|
+ if(order==null){
|
|
|
+ return R.error("订单不存在");
|
|
|
+ }
|
|
|
+ if(order.getStatus()!= OrderInfoEnum.STATUS_0.getValue()){
|
|
|
+ return R.error("订单状态不正确");
|
|
|
+ }
|
|
|
+ String orderId=redisCache.getCacheObject("isPaying:"+order.getOrderId());
|
|
|
+ if(StringUtils.isNotEmpty(orderId)&&orderId.equals(order.getOrderId().toString())){
|
|
|
+ return R.error("正在支付中...");
|
|
|
+ }
|
|
|
+ List<LiveOrderPayment> payments = liveOrderPaymentMapper.selectLiveOrderPaymentByOrderId(order.getOrderId());
|
|
|
+ if(payments.size()>0){
|
|
|
+ for(LiveOrderPayment payment : payments){
|
|
|
+ OrderQueryDTO orderQueryDTO = new OrderQueryDTO();
|
|
|
+ orderQueryDTO.setLowOrderId("live-"+payment.getPayCode());
|
|
|
+ OrderResult orderResult = ybPayService.getOrder(orderQueryDTO);
|
|
|
+ if(orderResult.getStatus()!= null&&orderResult.getStatus().equals("100")){
|
|
|
+ if(orderResult.getState()!=null&&orderResult.getState().equals("0")){
|
|
|
+ return R.error("订单已支付");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ FsUserScrm user=userService.selectFsUserById(Long.valueOf(order.getUserId()));
|
|
|
+ if(user!=null&& StringUtils.isNotEmpty(user.getMaOpenId())){
|
|
|
+ //已改价处理
|
|
|
+ if(order.getIsEditMoney()!=null&&order.getIsEditMoney()==1){
|
|
|
+ //改过价不做处理
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ String config=configService.selectConfigByKey("his.store");
|
|
|
+ StoreConfig storeConfig= JSONUtil.toBean(config,StoreConfig.class);
|
|
|
+ if(param.getPayType().equals(1)){
|
|
|
+ order.setPayType("1");
|
|
|
+ order.setPayMoney(order.getPayPrice());
|
|
|
+ order.setPayDelivery(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ else if(param.getPayType().equals(2)){
|
|
|
+
|
|
|
+ order.setPayType("2");
|
|
|
+ BigDecimal payMoney=order.getPayPrice().multiply(new BigDecimal(storeConfig.getPayRate())).divide(new BigDecimal(100));
|
|
|
+ payMoney=new BigDecimal(payMoney.setScale(0, BigDecimal.ROUND_HALF_UP).longValue());
|
|
|
+ order.setPayDelivery(order.getPayPrice().subtract(payMoney));
|
|
|
+ order.setPayMoney(payMoney);
|
|
|
+ }
|
|
|
+ else if(param.getPayType().equals(3)){
|
|
|
+ //货到付款
|
|
|
+ order.setPayType("3");
|
|
|
+// order.setPayDelivery(order.getPayPrice() );
|
|
|
+// order.setPayMoney(BigDecimal.ZERO);
|
|
|
+ BigDecimal amount=redisCache.getCacheObject("orderAmount:"+order.getOrderId());
|
|
|
+ BigDecimal payMoney = BigDecimal.ZERO;
|
|
|
+ if (amount != null){
|
|
|
+ payMoney=amount;
|
|
|
+ }
|
|
|
+ order.setPayMoney(payMoney);
|
|
|
+ order.setPayDelivery(order.getPayPrice().subtract(payMoney) );
|
|
|
+ }
|
|
|
+ orderService.updateLiveOrder(order);
|
|
|
+ }
|
|
|
+ return R.ok().put("order",order);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ return R.error("用户OPENID不存在");
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+// @Login
|
|
|
+// @ApiOperation("支付尾款")
|
|
|
+// @PostMapping("/payRemain")
|
|
|
+// @Transactional
|
|
|
+// public R payRemain(HttpServletRequest request, @Validated @RequestBody FsStoreOrderPayParam param) {
|
|
|
+// LiveOrder order=orderService.selectLiveOrderByOrderId(String.valueOf(param.getOrderId()));
|
|
|
+// if(order==null){
|
|
|
+// return R.error("订单不存在");
|
|
|
+// }
|
|
|
+// if(order.getStatus()!= OrderInfoEnum.STATUS_2.getValue()){
|
|
|
+// return R.error("待收货订单可申请支付尾款");
|
|
|
+// }
|
|
|
+// if(order.getPayType().equals(1)){
|
|
|
+// return R.error("此订单已支付");
|
|
|
+// }
|
|
|
+// //只有顺风才可以付尾
|
|
|
+// if(!order.getDeliverySn().trim().equals("SF")){
|
|
|
+// return R.error("只有顺丰物流支持尾款支付");
|
|
|
+// }
|
|
|
+//
|
|
|
+// if(!order.getIsPayRemain().equals(0)){
|
|
|
+// return R.error("此订单已支付");
|
|
|
+// }
|
|
|
+// FsUserScrm user=userService.selectFsUserById(order.getUserId());
|
|
|
+// if(user!=null&& StringUtils.isNotEmpty(user.getMaOpenId())){
|
|
|
+// String payCode = IdUtil.getSnowflake(0, 0).nextIdStr();
|
|
|
+// String json = configService.selectConfigByKey("his.pay");
|
|
|
+// FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
|
|
|
+// LiveOrderPayment storePayment=new LiveOrderPayment();
|
|
|
+// storePayment.setCompanyId(order.getCompanyId());
|
|
|
+// storePayment.setCompanyUserId(order.getCompanyUserId());
|
|
|
+// storePayment.setStatus(0);
|
|
|
+// storePayment.setPayMode(fsPayConfig.getType());
|
|
|
+// storePayment.setPayCode(payCode);
|
|
|
+// storePayment.setPayMoney(order.getPayDelivery());
|
|
|
+// storePayment.setCreateTime(new Date());
|
|
|
+// storePayment.setPayTypeCode("weixin");
|
|
|
+// storePayment.setBusinessType(2);
|
|
|
+// storePayment.setRemark("商城订单尾款支付");
|
|
|
+// storePayment.setOpenId(user.getRealName());
|
|
|
+// storePayment.setUserId(user.getUserId());
|
|
|
+// storePayment.setBusinessOrderId(order.getId().toString());
|
|
|
+// storePayment.setOrderId(order.getId());
|
|
|
+// storePayment.setIsPayRemain(1);
|
|
|
+// liveOrderPaymentMapper.insertFsStorePayment(storePayment);
|
|
|
+//
|
|
|
+// if (fsPayConfig.getType().equals("hf")){
|
|
|
+// HuiFuCreateOrder o = new HuiFuCreateOrder();
|
|
|
+// o.setTradeType("T_MINIAPP");
|
|
|
+// o.setOpenid(user.getMaOpenId());
|
|
|
+// o.setReqSeqId("store_remain-"+storePayment.getPayCode());
|
|
|
+// o.setTransAmt(storePayment.getPayMoney().toString());
|
|
|
+// o.setGoodsDesc("商城订单尾款支付");
|
|
|
+// HuifuCreateOrderResult result = huiFuService.createOrder(o);
|
|
|
+// //创建订单
|
|
|
+// if(result.getResp_code()!=null&&(result.getResp_code().equals("00000000")||result.getResp_code().equals("00000100"))){
|
|
|
+//
|
|
|
+// LiveOrderPayment mt=new LiveOrderPayment();
|
|
|
+// mt.setPaymentId(storePayment.getPaymentId());
|
|
|
+// mt.setTradeNo(result.getHf_seq_id());
|
|
|
+// liveOrderPaymentMapper.updateFsStorePayment(mt);
|
|
|
+// redisCache.setCacheObject("isPaying:"+order.getId(),order.getId().toString(),1, TimeUnit.MINUTES);
|
|
|
+// Map<String, Object> resultMap = JSON.parseObject(result.getPay_info(), new TypeReference<Map<String, Object>>() {});
|
|
|
+// String s = (String) resultMap.get("package");
|
|
|
+// resultMap.put("packageValue",s);
|
|
|
+// return R.ok().put("payType",param.getPayType()).put("result",resultMap);
|
|
|
+// }
|
|
|
+// else{
|
|
|
+// return R.error(result.getResp_desc());
|
|
|
+// }
|
|
|
+// }else if(fsPayConfig.getType().equals("wx")) {
|
|
|
+// WxPayConfig payConfig = new WxPayConfig();
|
|
|
+// payConfig.setAppId(fsPayConfig.getAppId());
|
|
|
+// payConfig.setMchId(fsPayConfig.getWxMchId());
|
|
|
+// payConfig.setMchKey(fsPayConfig.getWxMchKey());
|
|
|
+// payConfig.setSubAppId(org.apache.commons.lang3.StringUtils.trimToNull(null));
|
|
|
+// payConfig.setSubMchId(org.apache.commons.lang3.StringUtils.trimToNull(null));
|
|
|
+// payConfig.setKeyPath(null);
|
|
|
+// payConfig.setNotifyUrl(fsPayConfig.getNotifyUrlScrm());
|
|
|
+// wxPayService.setConfig(payConfig);
|
|
|
+// WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
|
|
|
+// orderRequest.setOpenid(user.getMaOpenId());//公众号支付提供用户openid
|
|
|
+// orderRequest.setBody("商城订单支付");
|
|
|
+// orderRequest.setOutTradeNo("store-" + storePayment.getPayCode());
|
|
|
+// orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(storePayment.getPayMoney().toString()));//测试
|
|
|
+// //orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(money));//测试
|
|
|
+// orderRequest.setTradeType("JSAPI");
|
|
|
+// orderRequest.setSpbillCreateIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
|
|
|
+// //调用统一下单接口,获取"预支付交易会话标识"
|
|
|
+// try {
|
|
|
+// WxPayMpOrderResult orderResult = wxPayService.createOrder(orderRequest);
|
|
|
+// return R.ok().put("result", orderResult).put("type", "wx").put("isPay", 0);
|
|
|
+// } catch (WxPayException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// throw new CustomException("支付失败" + e.getMessage());
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// else{
|
|
|
+// return R.error("用户OPENID不存在");
|
|
|
+// }
|
|
|
+// return R.error("无支付类型");
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
@Login
|
|
|
- @ApiOperation("微信支付")
|
|
|
- @PostMapping("/weChatPayment")
|
|
|
- @RepeatSubmit
|
|
|
- public R payment(@Validated @RequestBody FsUserLiveOrderPayUParam param)
|
|
|
- {
|
|
|
- param.setUserId(Long.parseLong(getUserId()));
|
|
|
- return liveOrderService.wxPayment(param);
|
|
|
- }
|
|
|
+ @ApiOperation("亲友支付")
|
|
|
+ @PostMapping("/otherPayment")
|
|
|
+ @Transactional
|
|
|
+ public R otherPayment(@Validated @RequestBody FsStoreOrderOtherPayParam param, HttpServletRequest request){
|
|
|
+ final WxMaService wxService = WxMaConfiguration.getMaService(properties.getConfigs().get(0).getAppid());
|
|
|
+ try {
|
|
|
+ String ip = IpUtil.getRequestIp();
|
|
|
+ WxMaJscode2SessionResult session = wxService.getUserService().getSessionInfo(param.getCode());
|
|
|
+ FsUserScrm user=userService.selectFsUserByMaOpenId(session.getOpenid());
|
|
|
+ if(user==null){
|
|
|
+ //创建
|
|
|
+ user=new FsUserScrm();
|
|
|
+ user.setUsername("");
|
|
|
+ user.setNickname("微信用户");
|
|
|
+ user.setStatus(1);
|
|
|
+ user.setMaOpenId(session.getOpenid());
|
|
|
+ user.setUnionId(session.getUnionid());
|
|
|
+ user.setIsWeixinAuth(0);
|
|
|
+ user.setLastIp(ip);
|
|
|
+ user.setCreateTime(new Date());
|
|
|
+ userService.insertFsUser(user);
|
|
|
+ }
|
|
|
+ LiveOrder order=orderService.selectLiveOrderByOrderId(String.valueOf(param.getOrderId()));
|
|
|
+ if(order==null){
|
|
|
+ return R.error("订单不存在");
|
|
|
+ }
|
|
|
+ if(order.getStatus()!= OrderInfoEnum.STATUS_0.getValue()){
|
|
|
+ return R.error("此订单不能支付");
|
|
|
+ }
|
|
|
+ if(order.getPayMoney().compareTo(new BigDecimal(0))<1){
|
|
|
+ return R.error("此订单没有可支付的金额");
|
|
|
+ }
|
|
|
|
|
|
- @Log(title = "退款", businessType = BusinessType.UPDATE)
|
|
|
- @PostMapping("/refundOrderMoney")
|
|
|
- public synchronized R refundOrderMoney(@Validated @RequestBody LiveOrderRefundParam param, HttpServletRequest request) {
|
|
|
- log.info("退款 {}",JSON.toJSONString(param));
|
|
|
+ String orderId=redisCache.getCacheObject("isPaying:"+order.getOrderId());
|
|
|
+ if(StringUtils.isNotEmpty(orderId)&&orderId.equals(order.getOrderId().toString())){
|
|
|
+ return R.error("正在支付中...");
|
|
|
+ }
|
|
|
|
|
|
- return liveOrderService.refundOrderMoney(param.getOrderId());
|
|
|
+ String json = configService.selectConfigByKey("his.pay");
|
|
|
+ FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
|
|
|
+ String payCode = IdUtil.getSnowflake(0, 0).nextIdStr();
|
|
|
+ //易宝支付
|
|
|
+ LiveOrderPayment storePayment=new LiveOrderPayment();
|
|
|
+ storePayment.setCompanyId(order.getCompanyId());
|
|
|
+ storePayment.setCompanyUserId(order.getCompanyUserId());
|
|
|
+ storePayment.setStatus(0);
|
|
|
+ storePayment.setPayCode(payCode);
|
|
|
+ storePayment.setPayMode(fsPayConfig.getType());
|
|
|
+ storePayment.setPayMoney(order.getPayMoney());
|
|
|
+ storePayment.setCreateTime(new Date());
|
|
|
+ storePayment.setPayTypeCode("weixin");
|
|
|
+ storePayment.setBusinessType(2);
|
|
|
+ storePayment.setRemark("商城订单支付");
|
|
|
+ storePayment.setOpenId(session.getOpenid());
|
|
|
+ storePayment.setUserId(user.getUserId());
|
|
|
+ storePayment.setBusinessId(order.getOrderId().toString());
|
|
|
+ liveOrderPaymentMapper.insertLiveOrderPayment(storePayment);
|
|
|
+
|
|
|
+ if (fsPayConfig.getType().equals("hf")){
|
|
|
+ HuiFuCreateOrder o = new HuiFuCreateOrder();
|
|
|
+ o.setTradeType("T_MINIAPP");
|
|
|
+ o.setOpenid(user.getMaOpenId());
|
|
|
+ o.setReqSeqId("store-"+storePayment.getPayCode());
|
|
|
+ o.setTransAmt(storePayment.getPayMoney().toString());
|
|
|
+ o.setGoodsDesc("商城订单支付");
|
|
|
+ HuifuCreateOrderResult result = huiFuService.createOrder(o);
|
|
|
+ if(result.getResp_code()!=null&&(result.getResp_code().equals("00000000")||result.getResp_code().equals("00000100"))){
|
|
|
+
|
|
|
+ LiveOrderPayment mt=new LiveOrderPayment();
|
|
|
+ mt.setPaymentId(storePayment.getPaymentId());
|
|
|
+ mt.setTradeNo(result.getHf_seq_id());
|
|
|
+ liveOrderPaymentMapper.updateLiveOrderPayment(mt);
|
|
|
+ redisCache.setCacheObject("isPaying:"+order.getOrderId(),order.getOrderId().toString(),1, TimeUnit.MINUTES);
|
|
|
+ Map<String, Object> resultMap = JSON.parseObject(result.getPay_info(), new TypeReference<Map<String, Object>>() {});
|
|
|
+ String s = (String) resultMap.get("package");
|
|
|
+ resultMap.put("packageValue",s);
|
|
|
+ return R.ok().put("result",resultMap);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ return R.error(result.getResp_desc());
|
|
|
+ }
|
|
|
+ }else if (fsPayConfig.getType().equals("wx")){
|
|
|
+ //创建微信订单
|
|
|
+ WxPayConfig payConfig = new WxPayConfig();
|
|
|
+ payConfig.setAppId(fsPayConfig.getAppId());
|
|
|
+ payConfig.setMchId(fsPayConfig.getWxMchId());
|
|
|
+ payConfig.setMchKey(fsPayConfig.getWxMchKey());
|
|
|
+ payConfig.setSubAppId(org.apache.commons.lang3.StringUtils.trimToNull(null));
|
|
|
+ payConfig.setSubMchId(org.apache.commons.lang3.StringUtils.trimToNull(null));
|
|
|
+ payConfig.setKeyPath(null);
|
|
|
+ payConfig.setNotifyUrl(fsPayConfig.getNotifyUrlScrm());
|
|
|
+ wxPayService.setConfig(payConfig);
|
|
|
+ WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
|
|
|
+ orderRequest.setOpenid(user.getMaOpenId());//公众号支付提供用户openid
|
|
|
+ orderRequest.setBody("商城订单支付");
|
|
|
+ orderRequest.setOutTradeNo("store-" + storePayment.getPayCode());
|
|
|
+ orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(storePayment.getPayMoney().toString()));//测试
|
|
|
+ //orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(money));//测试
|
|
|
+ orderRequest.setTradeType("JSAPI");
|
|
|
+ orderRequest.setSpbillCreateIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
|
|
|
+ //调用统一下单接口,获取"预支付交易会话标识"
|
|
|
+ try {
|
|
|
+ WxPayMpOrderResult orderResult = wxPayService.createOrder(orderRequest);
|
|
|
+ return R.ok().put("result", orderResult).put("type", "wx").put("isPay", 0);
|
|
|
+ } catch (WxPayException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ throw new CustomException("支付失败" + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (WxErrorException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return R.error(e.getMessage());
|
|
|
+ }
|
|
|
+ return R.error("无支付类型");
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 订单确认
|
|
|
- * */
|
|
|
@Login
|
|
|
- @GetMapping(value = "/updateConfirm/{orderId}/{type}")
|
|
|
- @RepeatSubmit
|
|
|
- public R cancelConfirm(@PathVariable String orderId,@PathVariable String type)
|
|
|
- {
|
|
|
- log.info("订单确认 参数 orderId: {} type: {}", orderId, type);
|
|
|
+ @ApiOperation("亲友支付")
|
|
|
+ @PostMapping("/otherPaymentRemain")
|
|
|
+ @Transactional
|
|
|
+ public R otherPaymentRemain(@Validated @RequestBody FsStoreOrderOtherPayParam param, HttpServletRequest request){
|
|
|
+ final WxMaService wxService = WxMaConfiguration.getMaService(properties.getConfigs().get(0).getAppid());
|
|
|
+ try {
|
|
|
+ String ip = IpUtil.getRequestIp();
|
|
|
+ WxMaJscode2SessionResult session = wxService.getUserService().getSessionInfo(param.getCode());
|
|
|
+ FsUserScrm user=userService.selectFsUserByMaOpenId(session.getOpenid());
|
|
|
+ if(user==null){
|
|
|
+ //创建
|
|
|
+ user=new FsUserScrm();
|
|
|
+ user.setUsername("");
|
|
|
+ user.setNickname("微信用户");
|
|
|
+ user.setStatus(1);
|
|
|
+ user.setMaOpenId(session.getOpenid());
|
|
|
+ user.setUnionId(session.getUnionid());
|
|
|
+ user.setIsWeixinAuth(0);
|
|
|
+ user.setLastIp(ip);
|
|
|
+ user.setCreateTime(new Date());
|
|
|
+ userService.insertFsUser(user);
|
|
|
+ }
|
|
|
+ LiveOrder order=orderService.selectLiveOrderByOrderId(String.valueOf(param.getOrderId()));
|
|
|
+ if(order==null){
|
|
|
+ return R.error("订单不存在");
|
|
|
+ }
|
|
|
+ if(order.getStatus()!= OrderInfoEnum.STATUS_2.getValue()){
|
|
|
+ return R.error("待收货订单可申请支付尾款");
|
|
|
+ }
|
|
|
+ if(order.getPayType().equals(1)){
|
|
|
+ return R.error("此订单已支付");
|
|
|
+ }
|
|
|
+ //只有顺风才可以付尾
|
|
|
+ if(!order.getDeliverySn().trim().equals("SF")){
|
|
|
+ return R.error("只有顺丰物流支持尾款支付");
|
|
|
+ }
|
|
|
|
|
|
- LiveOrder byId = liveOrderService.getById(orderId);
|
|
|
- List<Map<String, String>> allCodeDescMap = null;
|
|
|
- if (type.equals("0"))
|
|
|
- allCodeDescMap = LiveOrderCancleReason.getAllCodeDescMap();
|
|
|
- return R.ok().put("reason",allCodeDescMap).put("data",byId);
|
|
|
+ String payCode = IdUtil.getSnowflake(0, 0).nextIdStr();
|
|
|
+ String json = configService.selectConfigByKey("his.pay");
|
|
|
+ FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
|
|
|
+ LiveOrderPayment storePayment=new LiveOrderPayment();
|
|
|
+ storePayment.setCompanyId(order.getCompanyId());
|
|
|
+ storePayment.setCompanyUserId(order.getCompanyUserId());
|
|
|
+ storePayment.setStatus(0);
|
|
|
+ storePayment.setPayMode(fsPayConfig.getType());
|
|
|
+ storePayment.setPayCode(payCode);
|
|
|
+ storePayment.setPayMoney(order.getPayDelivery());
|
|
|
+ storePayment.setCreateTime(new Date());
|
|
|
+ storePayment.setPayTypeCode("weixin");
|
|
|
+ storePayment.setBusinessType(2);
|
|
|
+ storePayment.setRemark("直播订单尾款支付");
|
|
|
+ storePayment.setOpenId(user.getRealName());
|
|
|
+ storePayment.setUserId(user.getUserId());
|
|
|
+ storePayment.setBusinessId(order.getOrderId().toString());
|
|
|
+ liveOrderPaymentMapper.insertLiveOrderPayment(storePayment);
|
|
|
+
|
|
|
+ if (fsPayConfig.getType().equals("hf")){
|
|
|
+ HuiFuCreateOrder o = new HuiFuCreateOrder();
|
|
|
+ o.setTradeType("T_MINIAPP");
|
|
|
+ o.setOpenid(user.getMaOpenId());
|
|
|
+ o.setReqSeqId("live-"+storePayment.getPayCode());
|
|
|
+ o.setTransAmt(storePayment.getPayMoney().toString());
|
|
|
+ o.setGoodsDesc("直播订单支付");
|
|
|
+ HuifuCreateOrderResult result = huiFuService.createOrder(o);
|
|
|
+ if(result.getResp_code()!=null&&(result.getResp_code().equals("00000000")||result.getResp_code().equals("00000100"))){
|
|
|
+
|
|
|
+ LiveOrderPayment mt=new LiveOrderPayment();
|
|
|
+ mt.setPaymentId(storePayment.getPaymentId());
|
|
|
+ mt.setTradeNo(result.getHf_seq_id());
|
|
|
+ liveOrderPaymentMapper.updateLiveOrderPayment(mt);
|
|
|
+ redisCache.setCacheObject("isPaying:"+order.getOrderId(),order.getOrderId().toString(),1, TimeUnit.MINUTES);
|
|
|
+ Map<String, Object> resultMap = JSON.parseObject(result.getPay_info(), new TypeReference<Map<String, Object>>() {});
|
|
|
+ String s = (String) resultMap.get("package");
|
|
|
+ resultMap.put("packageValue",s);
|
|
|
+ return R.ok().put("result",resultMap);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ return R.error(result.getResp_desc());
|
|
|
+ }
|
|
|
+ }else if (fsPayConfig.getType().equals("wx")){
|
|
|
+ //创建微信订单
|
|
|
+ WxPayConfig payConfig = new WxPayConfig();
|
|
|
+ payConfig.setAppId(fsPayConfig.getAppId());
|
|
|
+ payConfig.setMchId(fsPayConfig.getWxMchId());
|
|
|
+ payConfig.setMchKey(fsPayConfig.getWxMchKey());
|
|
|
+ payConfig.setSubAppId(org.apache.commons.lang3.StringUtils.trimToNull(null));
|
|
|
+ payConfig.setSubMchId(org.apache.commons.lang3.StringUtils.trimToNull(null));
|
|
|
+ payConfig.setKeyPath(null);
|
|
|
+ payConfig.setNotifyUrl(fsPayConfig.getNotifyUrlScrm());
|
|
|
+ wxPayService.setConfig(payConfig);
|
|
|
+ WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
|
|
|
+ orderRequest.setOpenid(user.getMaOpenId());//公众号支付提供用户openid
|
|
|
+ orderRequest.setBody("直播订单支付");
|
|
|
+ orderRequest.setOutTradeNo("live-" + storePayment.getPayCode());
|
|
|
+ orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(storePayment.getPayMoney().toString()));//测试
|
|
|
+ //orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(money));//测试
|
|
|
+ orderRequest.setTradeType("JSAPI");
|
|
|
+ orderRequest.setSpbillCreateIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
|
|
|
+ //调用统一下单接口,获取"预支付交易会话标识"
|
|
|
+ try {
|
|
|
+ WxPayMpOrderResult orderResult = wxPayService.createOrder(orderRequest);
|
|
|
+ return R.ok().put("result", orderResult).put("type", "wx").put("isPay", 0);
|
|
|
+ } catch (WxPayException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ throw new CustomException("支付失败" + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (WxErrorException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return R.error(e.getMessage());
|
|
|
+ }
|
|
|
+ return R.error("无支付类型");
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- *正在购买的用户
|
|
|
- * */
|
|
|
- @GetMapping(value = "/liveOrderUser/{liveId}")
|
|
|
- public R liveOrderUser(@PathVariable String liveId)
|
|
|
- {
|
|
|
- log.info("正在购买的用户 参数: {}",liveId);
|
|
|
- return liveOrderService.liveOrderUser(liveId);
|
|
|
- }
|
|
|
|
|
|
@Login
|
|
|
@ApiOperation("取消订单")
|
|
|
@PostMapping("/cancelOrder")
|
|
|
- public R cancelOrder(@Validated @RequestBody LiveOrderCancelParam param, HttpServletRequest request){
|
|
|
- log.info("取消订单 参数: {}",JSON.toJSONString(param));
|
|
|
-
|
|
|
- LiveOrder order=liveOrderService.selectLiveOrderByOrderId(String.valueOf(param.getOrderId()));
|
|
|
+// @Log(title = "取消订单", businessType = BusinessType.UPDATE)
|
|
|
+ public R cancelOrder( @Validated @RequestBody FsStoreOrderCancelParam param, HttpServletRequest request){
|
|
|
+ LiveOrder order=orderService.selectLiveOrderByOrderId(String.valueOf(param.getOrderId()));
|
|
|
if (ObjectUtil.isNull(order)) {
|
|
|
throw new CustomException("订单不存在");
|
|
|
}
|
|
|
- return liveOrderService.cancelOrder(order);
|
|
|
+ if (order.getStatus() !=0) {
|
|
|
+ throw new CustomException("非法操作");
|
|
|
+ }
|
|
|
+ orderService.cancelOrder(order);
|
|
|
|
|
|
+ return R.ok("操作成功");
|
|
|
+ }
|
|
|
+ @Login
|
|
|
+ @ApiOperation("物流查询")
|
|
|
+ @PostMapping("/getExpress")
|
|
|
+ public R getExpress(@Validated @RequestBody FsStoreOrderExpressParam param, HttpServletRequest request){
|
|
|
+ LiveOrder order=orderService.selectLiveOrderByOrderId(String.valueOf(param.getOrderId()));
|
|
|
+ if (ObjectUtil.isNull(order)) {
|
|
|
+ throw new CustomException("订单不存在");
|
|
|
+ }
|
|
|
+ if (order.getStatus() <2) {
|
|
|
+ throw new CustomException("未发货订单不能查询");
|
|
|
+ }
|
|
|
+ return orderService.getExpress(order);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
@Login
|
|
|
@ApiOperation("完成订单")
|
|
|
@PostMapping("/finishOrder")
|
|
|
- public R finishOrder(@Validated @RequestBody LiveOrderCancelParam param, HttpServletRequest request){
|
|
|
- log.info("完成订单 参数: {}",JSON.toJSONString(param));
|
|
|
-
|
|
|
- return liveOrderService.finishOrder(param.getOrderId());
|
|
|
+ public R finishOrder( @Validated @RequestBody FsStoreOrderFinishParam param, HttpServletRequest request){
|
|
|
+ return orderService.finishOrder(param.getOrderId());
|
|
|
}
|
|
|
- @ApiOperation("完成订单")
|
|
|
- @GetMapping("/test")
|
|
|
- public R tes(){
|
|
|
- List<Long> ids = liveOrderService.selectOrderIdByNoErp();
|
|
|
- for (Long id : ids) {
|
|
|
- try{
|
|
|
- liveOrderService.createOmsOrder(id);
|
|
|
- }catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- return null;
|
|
|
+
|
|
|
+
|
|
|
+ @Login
|
|
|
+ @ApiOperation("获取订单总数")
|
|
|
+ @GetMapping("/getOrderCount")
|
|
|
+ public R getOrderCount( HttpServletRequest request){
|
|
|
+ Integer count0=orderService.selectFsStoreOrderCount(Long.parseLong(getUserId()),0);
|
|
|
+ Integer count1=orderService.selectFsStoreOrderCount(Long.parseLong(getUserId()),1);
|
|
|
+ Integer count2=orderService.selectFsStoreOrderCount(Long.parseLong(getUserId()),2);
|
|
|
+ Integer afterSalesCount=liveAfterSalesService.selectLiveAfterSalesCount(Long.parseLong(getUserId()),0);
|
|
|
+ return R.ok().put("count0",count0).put("count1",count1).put("count2",count2).put("afterSalesCount",afterSalesCount);
|
|
|
}
|
|
|
|
|
|
|