parent
8825ff18c9
commit
4fe20c8f83
File diff suppressed because one or more lines are too long
@ -0,0 +1,198 @@ |
||||
package com.web.controller.business; |
||||
|
||||
import com.alibaba.excel.EasyExcel; |
||||
import com.alibaba.fastjson.JSONArray; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.github.pagehelper.PageHelper; |
||||
import com.github.pagehelper.PageInfo; |
||||
import com.hai.common.exception.ErrorCode; |
||||
import com.hai.common.exception.ErrorHelp; |
||||
import com.hai.common.exception.SysCode; |
||||
import com.hai.common.security.UserCenter; |
||||
import com.hai.common.utils.DateUtil; |
||||
import com.hai.common.utils.PageUtil; |
||||
import com.hai.common.utils.ResponseMsgUtil; |
||||
import com.hai.entity.*; |
||||
import com.hai.enum_type.UserObjectTypeEnum; |
||||
import com.hai.goods.model.GoodsModel; |
||||
import com.hai.goods.service.GoodsLogisticsService; |
||||
import com.hai.goods.service.GoodsOrderExtService; |
||||
import com.hai.goods.service.GoodsSkuService; |
||||
import com.hai.model.ResponseData; |
||||
import com.hai.model.UserInfoModel; |
||||
import com.hai.order.model.ExportOrderMobileModel; |
||||
import com.hai.order.model.GoodsOrderExtModel; |
||||
import com.hai.order.service.OrderService; |
||||
import com.hai.order.type.OrderPayType; |
||||
import com.hai.order.type.OrderStatus; |
||||
import com.hai.order.type.RechargePlatformType; |
||||
import com.hai.service.OutRechargeChildOrderService; |
||||
import com.hai.service.OutRechargeOrderService; |
||||
import com.web.config.SysConst; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.apache.commons.math3.stat.correlation.PearsonsCorrelation; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.beans.BeanUtils; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestMethod; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.ResponseBody; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.io.File; |
||||
import java.util.*; |
||||
import java.util.stream.Collectors; |
||||
|
||||
@Controller |
||||
@RequestMapping(value = "goodsOrder") |
||||
@Api(value = "实物商品业务") |
||||
public class GoodsOrderController { |
||||
|
||||
private static Logger log = LoggerFactory.getLogger(OrderMobileRechargeController.class); |
||||
|
||||
@Resource |
||||
private UserCenter userCenter; |
||||
|
||||
@Resource |
||||
private OrderService orderService; |
||||
|
||||
@Resource |
||||
private GoodsOrderExtService goodsOrderExtService; |
||||
|
||||
@Resource |
||||
private GoodsLogisticsService goodsLogisticsService; |
||||
|
||||
@RequestMapping(value = "/getOrderList", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询订单列表") |
||||
public ResponseData getOrderList(@RequestParam(name = "orderNo", required = false) String orderNo, |
||||
@RequestParam(name = "memPhone", required = false) String memPhone, |
||||
@RequestParam(name = "memCardNo", required = false) String memCardNo, |
||||
@RequestParam(name = "payType", required = false) Integer payType, |
||||
@RequestParam(name = "orderStatus", required = false) Integer orderStatus, |
||||
@RequestParam(name = "companyId", required = false) Long companyId, |
||||
@RequestParam(name = "createTimeS", required = false) Long createTimeS, |
||||
@RequestParam(name = "createTimeE", required = false) Long createTimeE, |
||||
@RequestParam(name = "refundTimeS", required = false) String refundTimeS, |
||||
@RequestParam(name = "refundTimeE", required = false) String refundTimeE, |
||||
@RequestParam(name = "payTimeS", required = false) Long payTimeS, |
||||
@RequestParam(name = "payTimeE", required = false) Long payTimeE, |
||||
@RequestParam(name = "productType", required = false) Integer productType, |
||||
@RequestParam(name = "finishTimeS", required = false) Long finishTimeS, |
||||
@RequestParam(name = "finishTimeE", required = false) Long finishTimeE, |
||||
@RequestParam(name = "pageNum", required = true) Integer pageNum, |
||||
@RequestParam(name = "pageSize", required = true) Integer pageSize, |
||||
HttpServletRequest request) { |
||||
try { |
||||
|
||||
UserInfoModel userInfoModel = userCenter.getSessionModel(UserInfoModel.class); |
||||
if (userInfoModel == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); |
||||
} |
||||
Map<String,Object> map = new HashMap<>(); |
||||
if (userInfoModel.getSecUser().getObjectType().equals(UserObjectTypeEnum.type0.getType())) { |
||||
map.put("companyId" , companyId); |
||||
} else if (userInfoModel.getSecUser().getObjectType().equals(UserObjectTypeEnum.type1.getType())) { |
||||
map.put("companyId", userInfoModel.getBsCompany().getId()); |
||||
} else { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); |
||||
} |
||||
map.put("createTimeS", createTimeS); |
||||
map.put("createTimeE", createTimeE); |
||||
map.put("payTimeS", payTimeS); |
||||
map.put("payTimeE", payTimeE); |
||||
map.put("finishTimeS", finishTimeS); |
||||
map.put("finishTimeE", finishTimeE); |
||||
map.put("refundTimeS" , refundTimeS); |
||||
map.put("refundTimeE" , refundTimeE); |
||||
map.put("orderNo", orderNo); |
||||
map.put("memPhone", memPhone); |
||||
map.put("memCardNo", memCardNo); |
||||
map.put("productType", 12); |
||||
map.put("orderStatus", orderStatus); |
||||
map.put("payType", payType); |
||||
|
||||
List<HighOrder> list = orderService.getOrderList(map); |
||||
|
||||
List<GoodsOrderExtModel> goodsOrderExtModels = new ArrayList<>(); |
||||
|
||||
GoodsOrderExtModel model; |
||||
|
||||
for (HighOrder order : list) { |
||||
model = new GoodsOrderExtModel(); |
||||
BeanUtils.copyProperties(order, model); |
||||
model.setLogisticsStatus(goodsOrderExtService.findGoodsOrder(order.getOrderNo()).getStatus()); |
||||
goodsOrderExtModels.add(model); |
||||
} |
||||
goodsOrderExtModels = goodsOrderExtModels.stream().sorted(Comparator.comparing(GoodsOrderExtModel::getLogisticsStatus)).collect(Collectors.toList()); |
||||
|
||||
return ResponseMsgUtil.success(PageUtil.initPageInfoObj(pageNum, goodsOrderExtModels.size(), pageSize, new PageInfo<>(goodsOrderExtModels))); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("OrderCouponController --> getOrderList() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value="/getGoodsOrderDetail",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询订单详情") |
||||
public ResponseData getMobileOrderDetail(@RequestParam(name = "orderNo", required = true) String orderNo) { |
||||
try { |
||||
Map<String, Object> map = new HashMap<>(); |
||||
map.put("tradeOrder", orderService.getOrderDetailByNo(orderNo)); |
||||
GoodsOrder goodsOrder = goodsOrderExtService.findGoodsOrder(orderNo); |
||||
map.put("goodsOrder", goodsOrder); |
||||
if (goodsOrder.getLogisticsNo() != null) { |
||||
GoodsLogistics logistics = (GoodsLogistics) goodsLogisticsService.getLogisticsMsg(goodsOrder.getLogisticsNo()); |
||||
map.put("logistics", logistics); |
||||
JSONArray object = JSONArray.parseArray(logistics.getLogisticsTraceDetails()); |
||||
map.put("logisticsTraceDetails", object); |
||||
} |
||||
|
||||
return ResponseMsgUtil.success(map); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("OrderExtController -> getGasOrderDetail() error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
|
||||
@RequestMapping(value="/updateLogisticsNo",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "更新物流订单号") |
||||
public ResponseData updateLogisticsNo(@RequestParam(name = "orderNo", required = true) String orderNo, |
||||
@RequestParam(name = "logisticsNo", required = true) String logisticsNo |
||||
) { |
||||
try { |
||||
|
||||
GoodsOrder goodsOrder = goodsOrderExtService.findGoodsOrder(orderNo); |
||||
|
||||
if (goodsOrder == null) { |
||||
throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "信息错误!"); |
||||
} |
||||
|
||||
goodsOrder.setLogisticsNo(logisticsNo); |
||||
goodsOrder.setUpdateTime(new Date()); |
||||
if (Objects.equals(goodsOrder.getStatus(), "1")) { |
||||
goodsOrder.setStatus("2"); |
||||
} |
||||
|
||||
goodsOrderExtService.updateGoodsOrder(goodsOrder); |
||||
|
||||
return ResponseMsgUtil.success("更新成功!"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("OrderExtController -> getGasOrderDetail() error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,88 @@ |
||||
package com.hai.goods.service; |
||||
|
||||
import com.hai.entity.GoodsOrder; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @serviceName GoodsOrderService.java |
||||
* @author Sum1Dream |
||||
* @version 1.0.0 |
||||
* @Description // 商品订单业务
|
||||
* @createTime 17:52 2023/4/18 |
||||
**/ |
||||
public interface GoodsOrderExtService { |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name insertGoodsOrder |
||||
* @Description // 新增
|
||||
* @Date 15:08 2023/4/11 |
||||
* @Param [GoodsOrder] |
||||
* @Return void |
||||
*/ |
||||
void insertGoodsOrder(GoodsOrder goodsOrder); |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name updateGoodsOrder |
||||
* @Description // 更新
|
||||
* @Date 15:14 2023/4/11 |
||||
* @Param [GoodsOrder] |
||||
* @Return void |
||||
*/ |
||||
void updateGoodsOrder(GoodsOrder goodsOrder); |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name getGoodsOrderList |
||||
* @Description // 查询
|
||||
* @Date 15:17 2023/4/11 |
||||
* @Param [map] |
||||
* @Return java.util.List<com.hai.entity.GoodsOrder> |
||||
*/ |
||||
List<GoodsOrder> getGoodsOrderList(Map<String , Object> map); |
||||
|
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name findGoodsOrderById |
||||
* @Description // 根据id查询详情
|
||||
* @Date 16:19 2023/4/11 |
||||
* @Param [id] |
||||
* @Return com.hai.entity.GoodsOrder |
||||
*/ |
||||
GoodsOrder findGoodsOrderById(Long id); |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name findGoodsOrder |
||||
* @Description // 查询详情
|
||||
* @Date 15:44 2023/4/20 |
||||
* @Param [orderNo] |
||||
* @Return com.hai.entity.GoodsOrder |
||||
*/ |
||||
GoodsOrder findGoodsOrder(String orderNo); |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name findGoodsOrderByLogisticsNo |
||||
* @Description // 根据运单号查询订单
|
||||
* @Date 17:20 2023/4/20 |
||||
* @Param [logisticsNo] |
||||
* @Return com.hai.entity.GoodsOrder |
||||
*/ |
||||
GoodsOrder findGoodsOrderByLogisticsNo(String logisticsNo); |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name deleteGoodsOrder |
||||
* @Description // 删除
|
||||
* @Date 17:37 2023/4/13 |
||||
* @Param [id] |
||||
* @Return void |
||||
*/ |
||||
void deleteGoodsOrder(Long id); |
||||
|
||||
} |
@ -0,0 +1,72 @@ |
||||
package com.hai.goods.service.impl; |
||||
|
||||
import com.hai.dao.GoodsOrderMapper; |
||||
import com.hai.entity.GoodsOrder; |
||||
import com.hai.entity.GoodsOrderExample; |
||||
import com.hai.goods.service.GoodsOrderExtService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@Service("goodsOrderExtService") |
||||
public class GoodsOrderServiceImpl implements GoodsOrderExtService { |
||||
|
||||
@Resource |
||||
private GoodsOrderMapper goodsOrderMapper; |
||||
|
||||
@Override |
||||
public void insertGoodsOrder(GoodsOrder goodsOrder) { |
||||
goodsOrderMapper.insert(goodsOrder); |
||||
} |
||||
|
||||
@Override |
||||
public void updateGoodsOrder(GoodsOrder goodsOrder) { |
||||
goodsOrderMapper.updateByPrimaryKey(goodsOrder); |
||||
} |
||||
|
||||
@Override |
||||
public List<GoodsOrder> getGoodsOrderList(Map<String, Object> map) { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public GoodsOrder findGoodsOrderById(Long id) { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public GoodsOrder findGoodsOrder(String orderNo) { |
||||
|
||||
GoodsOrderExample example = new GoodsOrderExample(); |
||||
example.createCriteria().andStatusNotEqualTo("0").andOrderNoEqualTo(orderNo); |
||||
|
||||
List<GoodsOrder> list = goodsOrderMapper.selectByExample(example); |
||||
|
||||
if (list.size() > 0) { |
||||
return list.get(0); |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public GoodsOrder findGoodsOrderByLogisticsNo(String logisticsNo) { |
||||
GoodsOrderExample example = new GoodsOrderExample(); |
||||
example.createCriteria().andStatusNotEqualTo("0").andLogisticsNoEqualTo(logisticsNo); |
||||
|
||||
List<GoodsOrder> list = goodsOrderMapper.selectByExample(example); |
||||
|
||||
if (list.size() > 0) { |
||||
return list.get(0); |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void deleteGoodsOrder(Long id) { |
||||
|
||||
} |
||||
} |
@ -0,0 +1,28 @@ |
||||
package com.hai.model; |
||||
|
||||
import com.hai.entity.GoodsDeliveryAddress; |
||||
import com.hai.entity.GoodsOrder; |
||||
import com.hai.entity.HighOrder; |
||||
|
||||
public class GoodsOrderModel extends HighOrder { |
||||
|
||||
GoodsOrder goodsOrder; |
||||
|
||||
GoodsDeliveryAddress goodsDeliveryAddress; |
||||
|
||||
public GoodsOrder getGoodsOrder() { |
||||
return goodsOrder; |
||||
} |
||||
|
||||
public void setGoodsOrder(GoodsOrder goodsOrder) { |
||||
this.goodsOrder = goodsOrder; |
||||
} |
||||
|
||||
public GoodsDeliveryAddress getGoodsDeliveryAddress() { |
||||
return goodsDeliveryAddress; |
||||
} |
||||
|
||||
public void setGoodsDeliveryAddress(GoodsDeliveryAddress goodsDeliveryAddress) { |
||||
this.goodsDeliveryAddress = goodsDeliveryAddress; |
||||
} |
||||
} |
@ -0,0 +1,19 @@ |
||||
package com.hai.order.model; |
||||
|
||||
import com.hai.entity.HighOrder; |
||||
|
||||
public class GoodsOrderExtModel extends HighOrder { |
||||
|
||||
/** |
||||
* 1:待发货 2:已发货 3:配送中 4:已送达 5:已取消 6:退货中 7:已退货 8:待支付 0:删除'; |
||||
*/ |
||||
private String logisticsStatus; |
||||
|
||||
public String getLogisticsStatus() { |
||||
return logisticsStatus; |
||||
} |
||||
|
||||
public void setLogisticsStatus(String logisticsStatus) { |
||||
this.logisticsStatus = logisticsStatus; |
||||
} |
||||
} |
@ -0,0 +1,110 @@ |
||||
package com.v1.controller.business; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hai.common.exception.ErrorCode; |
||||
import com.hai.common.exception.ErrorHelp; |
||||
import com.hai.common.exception.SysCode; |
||||
import com.hai.common.utils.ResponseMsgUtil; |
||||
import com.hai.entity.ApiMerchants; |
||||
import com.hai.model.ResponseData; |
||||
import com.hai.service.ApiIpAddressService; |
||||
import com.hai.service.ApiMerchantsService; |
||||
import com.hai.service.BsOrderRebateService; |
||||
import com.hai.service.SecConfigService; |
||||
import com.hai.service.impl.OutRechargeOrderServiceImpl; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.RequestBody; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestMethod; |
||||
import org.springframework.web.bind.annotation.ResponseBody; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.Date; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
@Controller |
||||
@RequestMapping(value = "/orderRebate") |
||||
@Api(value = "订单返利") |
||||
public class OrderRebateController { |
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(OutRechargeOrderServiceImpl.class); |
||||
|
||||
@Resource |
||||
private BsOrderRebateService bsOrderRebateService; |
||||
|
||||
@Resource |
||||
private ApiMerchantsService apiMerchantsService; |
||||
|
||||
@Resource |
||||
private SecConfigService secConfigService; |
||||
|
||||
@Resource |
||||
private ApiIpAddressService apiIpAddressService; |
||||
|
||||
@RequestMapping(value = "/rebate", method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "积分返利") |
||||
public ResponseData rebate(@RequestBody JSONObject object , HttpServletRequest request ) { |
||||
try { |
||||
|
||||
String ip = ""; |
||||
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
|
||||
if (request.getHeader("x-forwarded-for") == null) { |
||||
ip = request.getRemoteAddr(); |
||||
} else { |
||||
ip = request.getHeader("x-forwarded-for"); |
||||
} |
||||
|
||||
if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { |
||||
log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); |
||||
} |
||||
|
||||
if (StringUtils.isBlank(object.getString("apiKey")) || |
||||
StringUtils.isBlank(object.getString("merchId")) || |
||||
StringUtils.isBlank(object.getString("sign")) |
||||
) { |
||||
log.error("getRechargeProduct error!", "请求参数校验失败!"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR); |
||||
} |
||||
|
||||
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId")); |
||||
|
||||
if (apiMerchants == null) { |
||||
log.error("getRechargeProduct error!", "商户号错误!"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST); |
||||
} |
||||
|
||||
Map<String , Object> map = new HashMap<>(); |
||||
map.put("apiKey" , object.getString("apiKey")); |
||||
map.put("merchId" , object.getString("merchId")); |
||||
map.put("userId" , object.getString("userId")); |
||||
map.put("productType" , object.getInteger("productType")); |
||||
map.put("orderNo" , object.getString("orderNo")); |
||||
map.put("orderId" , object.getLong("orderId")); |
||||
map.put("price" , object.getBigDecimal("price")); |
||||
map.put("title" , object.getString("title")); |
||||
map.put("createTime" , object.getDate("createTime")); |
||||
|
||||
if (!secConfigService.isSignVerify(map , object.getString("sign"))) { |
||||
log.error("getRechargeProduct error!", "签名校验失败!"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY); |
||||
} |
||||
|
||||
bsOrderRebateService.insertOrderRebate(object); |
||||
|
||||
return ResponseMsgUtil.success("赠送成功"); |
||||
} catch (Exception e) { |
||||
log.error("HighOrderController --> getBackendToken() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue