|
@@ -1,32 +1,9 @@
|
|
|
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.feign.bean.SzwlFeign;
|
|
|
-import com.szwl.model.bean.CoinOrderVo;
|
|
|
-import com.szwl.model.bo.JsonMessage;
|
|
|
-import com.szwl.model.bo.R;
|
|
|
-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 org.apache.commons.lang.StringUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.text.ParseException;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -34,163 +11,10 @@ import java.util.List;
|
|
|
* </p>
|
|
|
*
|
|
|
* @author wuhs
|
|
|
- * @since 2022-06-17
|
|
|
+ * @since 2023-08-10
|
|
|
*/
|
|
|
@RestController
|
|
|
-@RequestMapping("/api/coinOrder")
|
|
|
+@RequestMapping("/tCoinOrder")
|
|
|
public class TCoinOrderController {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- TCoinOrderService coinOrderService;
|
|
|
- @Autowired
|
|
|
- EsTCoinOrderService esTCoinOrderService;
|
|
|
- @Autowired
|
|
|
- SzwlFeign szwlFeign;
|
|
|
- /**添加线下
|
|
|
- * @param coinOrderVo
|
|
|
- * @return
|
|
|
- */
|
|
|
- @PostMapping("/saveCoinOrder")
|
|
|
- @ResponseBody
|
|
|
- public Object saveConinOrder(@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;
|
|
|
- }
|
|
|
}
|
|
|
|