|
@@ -1,32 +1,58 @@
|
|
|
package com.szwl.controller;
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.gexin.fastjson.JSON;
|
|
|
+import com.szwl.constant.ResponseCodesEnum;
|
|
|
+import com.szwl.feign.EsFeign;
|
|
|
import com.szwl.feign.SzwlFeign;
|
|
|
import com.szwl.feign.bean.TAdminParam;
|
|
|
+import com.szwl.model.bean.CoinOrderVO;
|
|
|
+import com.szwl.model.bo.JsonMessage;
|
|
|
import com.szwl.model.bo.R;
|
|
|
import com.szwl.model.bo.ResponseModel;
|
|
|
+import com.szwl.model.entity.TCoinOrder;
|
|
|
+import com.szwl.model.entity.TEquipment;
|
|
|
+import com.szwl.model.query.OrderStatisticsDTO;
|
|
|
+import com.szwl.model.query.Pageable;
|
|
|
+import com.szwl.model.utils.JsonUtils;
|
|
|
+import com.szwl.service.TCoinOrderService;
|
|
|
+import com.szwl.service.es.EsTCoinOrderService;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
|
- * 线下支付订单 前端控制器
|
|
|
+ * 前端控制器
|
|
|
* </p>
|
|
|
*
|
|
|
* @author wuhs
|
|
|
- * @since 2022-06-14
|
|
|
+ * @since 2023-08-10
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping("/tCoinOrder")
|
|
|
public class TCoinOrderController {
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
SzwlFeign szwlFeign;
|
|
|
+ @Autowired
|
|
|
+ EsTCoinOrderService esTCoinOrderService;
|
|
|
+ @Autowired
|
|
|
+ TCoinOrderService coinOrderService;
|
|
|
+// @Resource
|
|
|
+// EsFeign esFeign;
|
|
|
|
|
|
@ApiOperation(value = "测试feign")
|
|
|
@GetMapping("/testFeign")
|
|
@@ -34,5 +60,165 @@ public class TCoinOrderController {
|
|
|
List list = R.getDataIfSuccess(szwlFeign.testList(new TAdminParam().setName(name)));
|
|
|
return R.ok(list);
|
|
|
}
|
|
|
+
|
|
|
+// @ApiOperation(value = "同步订单到es中")
|
|
|
+// @PostMapping("/saveOrderAbroadToEs")
|
|
|
+// public ResponseModel<?> saveToEs(@RequestBody TCoinOrder coinOrder){
|
|
|
+// if(coinOrder==null){
|
|
|
+// return R.fail(ResponseCodesEnum.A0001);
|
|
|
+// }
|
|
|
+// esFeign.saveOrderAbroadToEs(coinOrder);
|
|
|
+// return R.ok("同步es成功");
|
|
|
+// }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存 线下 订单
|
|
|
+ * @param coinOrderVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/saveCoinOrder")
|
|
|
+ @ResponseBody
|
|
|
+ public Object saveCoinOrder(@RequestBody CoinOrderVO coinOrderVO) {
|
|
|
+ String clientId = coinOrderVO.getClientId();
|
|
|
+ String name = coinOrderVO.getName();
|
|
|
+ Integer payType = coinOrderVO.getPayType();
|
|
|
+ BigDecimal price = coinOrderVO.getPrice();
|
|
|
+ String sn = coinOrderVO.getSn();
|
|
|
+ TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(clientId));
|
|
|
+ Long adminId = equipment.getAdminId();
|
|
|
+ if (adminId == null) {
|
|
|
+ return JsonMessage.error("找不到设备商家");
|
|
|
+ }
|
|
|
+
|
|
|
+ TCoinOrder coinOrder = new TCoinOrder();
|
|
|
+ coinOrder.setType(null);
|
|
|
+ coinOrder.setClientId(clientId);
|
|
|
+ coinOrder.setAdminId(adminId);
|
|
|
+ coinOrder.setProductName(name);
|
|
|
+ coinOrder.setPayType(payType);
|
|
|
+ coinOrder.setPrice(price);
|
|
|
+ coinOrder.setProductNo(coinOrderVO.getNo());
|
|
|
+ coinOrder.setSn(sn);
|
|
|
+ if(coinOrderVO.getProductNumber()==null||coinOrderVO.getProductNumber()==0){
|
|
|
+ coinOrderVO.setProductNumber(1);
|
|
|
+ }else {
|
|
|
+ coinOrder.setProductNumber(coinOrderVO.getProductNumber());
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(coinOrderVO.getCreateDate())){
|
|
|
+ java.text.SimpleDateFormat formatter = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss");
|
|
|
+ Date date1 = null;
|
|
|
+ try {
|
|
|
+ date1 = formatter.parse(coinOrderVO.getCreateDate());
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ coinOrder.setCreateDate(date1);
|
|
|
+ coinOrder.setModifyDate(date1);
|
|
|
+ coinOrder.setPayDate(date1);
|
|
|
+ }else{
|
|
|
+ coinOrder.setCreateDate(new Date());
|
|
|
+ coinOrder.setModifyDate(new Date());
|
|
|
+ coinOrder.setPayDate(new Date());
|
|
|
+ }
|
|
|
+ coinOrderService.save(coinOrder);
|
|
|
+ try {
|
|
|
+ esTCoinOrderService.insertData(coinOrder);
|
|
|
+ }catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return JsonMessage.success("添加线下订单成功");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //设备查询线下订单记录
|
|
|
+ @RequestMapping(value = "/findCoinOrder", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
|
|
|
+ @ResponseBody
|
|
|
+ public String list(String clientId, String sn, String productName, Integer payType, Date begin, Date end, Pageable pageable) {
|
|
|
+ LambdaQueryWrapper<TCoinOrder> query = Wrappers.lambdaQuery();
|
|
|
+ if (StringUtils.isNotEmpty(sn)) {
|
|
|
+ query.eq(TCoinOrder::getSn,sn);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(productName)) {
|
|
|
+ query.eq(TCoinOrder::getProductName,productName);
|
|
|
+ }
|
|
|
+ if (payType != null) {
|
|
|
+ query.eq(TCoinOrder::getPayType,payType);
|
|
|
+ }
|
|
|
+ if (begin != null && end != null) {
|
|
|
+ query.gt(TCoinOrder::getPayDate,begin);
|
|
|
+ query.lt(TCoinOrder::getPayDate,end);
|
|
|
+ }
|
|
|
+ query.eq(TCoinOrder::getClientId,clientId);
|
|
|
+ int size = pageable.getPageSize();
|
|
|
+ int current = pageable.getPageNumber();
|
|
|
+ Page<TCoinOrder> page = new Page<>(current, size, true);
|
|
|
+ IPage<TCoinOrder> iPage = coinOrderService.page(page, query);
|
|
|
+ long total = page.getTotal();
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("total", total);
|
|
|
+ jsonObject.put("coinorders", JSON.toJSONString(iPage.getRecords()));
|
|
|
+ return jsonObject.toJSONString();
|
|
|
+ }
|
|
|
+
|
|
|
+ //设备查询线下订单记录
|
|
|
+ @RequestMapping(value = "/newFindCoinOrder", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
|
|
|
+ @ResponseBody
|
|
|
+ public String newFindCoinOrder(String clientId, String sn, String productName, Integer payType, String begin,String end, Pageable pageable) {
|
|
|
+ LambdaQueryWrapper<TCoinOrder> query = Wrappers.lambdaQuery();
|
|
|
+ java.text.SimpleDateFormat formatter = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss");
|
|
|
+ Date date1 = null;
|
|
|
+ Date date2 = null;
|
|
|
+ try {
|
|
|
+ date1 = formatter.parse(begin);
|
|
|
+ date2 = formatter.parse(end);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(sn)) {
|
|
|
+ query.eq(TCoinOrder::getSn,sn);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(productName)) {
|
|
|
+ query.eq(TCoinOrder::getProductName,productName);
|
|
|
+ }
|
|
|
+ if (payType != null) {
|
|
|
+ query.eq(TCoinOrder::getPayType,payType);
|
|
|
+ }
|
|
|
+ if (begin != null && end != null) {
|
|
|
+ query.gt(TCoinOrder::getPayDate,begin);
|
|
|
+ query.lt(TCoinOrder::getPayDate,end);
|
|
|
+ }
|
|
|
+ query.eq(TCoinOrder::getClientId,clientId);
|
|
|
+ int size = pageable.getPageSize();
|
|
|
+ int current = pageable.getPageNumber();
|
|
|
+ Page<TCoinOrder> page = new Page<>(current, size, true);
|
|
|
+ IPage<TCoinOrder> iPage = coinOrderService.page(page, query);
|
|
|
+ long total = page.getTotal();
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("total", total);
|
|
|
+ jsonObject.put("coinorders", JSON.toJSONString(iPage.getRecords()));
|
|
|
+ return jsonObject.toJSONString();
|
|
|
+ }
|
|
|
+
|
|
|
+ //设备查看线下汇总统计
|
|
|
+ @RequestMapping(value = "/listCoin", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
|
|
|
+ @ResponseBody
|
|
|
+ public Object findByTime(String clientId, String startTime, String endTime) {
|
|
|
+ java.text.SimpleDateFormat formatter = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss");
|
|
|
+ Date date1 = null;
|
|
|
+ Date date2 = null;
|
|
|
+ try {
|
|
|
+ date1 = formatter.parse(startTime);
|
|
|
+ date2 = formatter.parse(endTime);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ List<OrderStatisticsDTO> list = coinOrderService.findTotalByTime(clientId, date1, date2);
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("code", 0);
|
|
|
+ jsonObject.put("data", JsonUtils.toJson(list));
|
|
|
+ jsonObject.put("errmsg", "");
|
|
|
+ return jsonObject;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|