parent
9b602015f5
commit
33dc227e46
@ -0,0 +1,181 @@ |
||||
package com.cweb.controller.meal; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hfkj.channel.lakala.LaKaLaTradeService; |
||||
import com.hfkj.channel.tianque.service.TianQueTradeService; |
||||
import com.hfkj.common.exception.BaseException; |
||||
import com.hfkj.common.exception.ErrorCode; |
||||
import com.hfkj.common.exception.ErrorHelp; |
||||
import com.hfkj.common.exception.SysCode; |
||||
import com.hfkj.common.utils.ResponseMsgUtil; |
||||
import com.hfkj.config.CommonSysConst; |
||||
import com.hfkj.entity.*; |
||||
import com.hfkj.model.ResponseData; |
||||
import com.hfkj.service.BsMerPlatformNoService; |
||||
import com.hfkj.service.BsTradeOrderService; |
||||
import com.hfkj.service.meal.BsMealTableOrderService; |
||||
import com.hfkj.sysenum.*; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.apache.commons.collections4.MapUtils; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.data.redis.core.RedisTemplate; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.*; |
||||
|
||||
/** |
||||
* @className: BsMealShopCartController |
||||
* @author: HuRui |
||||
* @date: 2023/11/30 |
||||
**/ |
||||
@Controller |
||||
@Api(value = "桌台订单管理") |
||||
@RequestMapping(value = "/mealTableOrderPay") |
||||
public class BsMealTableOrderPayController { |
||||
|
||||
Logger log = LoggerFactory.getLogger(BsMealTableController.class); |
||||
|
||||
@Resource |
||||
private BsTradeOrderService tradeOrderService; |
||||
@Resource |
||||
private BsMealTableOrderService mealTableOrderService; |
||||
@Resource |
||||
private BsMerPlatformNoService merPlatformNoService; |
||||
@Resource |
||||
private LaKaLaTradeService laKaLaTradeService; |
||||
@Resource |
||||
private TianQueTradeService tianQueTradeService; |
||||
@Autowired |
||||
private RedisTemplate redisTemplate; |
||||
|
||||
@RequestMapping(value="/payOrder",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "支付订单") |
||||
public ResponseData payOrder(@RequestBody JSONObject body, HttpServletRequest request) { |
||||
try { |
||||
if (body == null || StringUtils.isBlank(body.getString("orderNo")) || StringUtils.isBlank(body.getString("payUserId"))) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
// 支付订单
|
||||
BsMealTableOrder tableOrder = mealTableOrderService.getTableOrderByOrderNo(body.getString("orderNo")); |
||||
if (tableOrder == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的订单号"); |
||||
} |
||||
if (!tableOrder.getStatus().equals(MealTableOrderStatusEnum.status1.getNumber())) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态异常"); |
||||
} |
||||
if (!tableOrder.getPayStatus().equals(MealTableOrderPayStatusEnum.status1.getNumber())) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "小伙伴正在支付中或已支付"); |
||||
} |
||||
String lockKey = "MEAL_ORDER_PAY_" + tableOrder.getOrderNo(); |
||||
try { |
||||
Boolean lock = redisTemplate.opsForValue().setIfAbsent(lockKey, null); |
||||
if(lock) { |
||||
// 加锁成功
|
||||
// 查询交易渠道
|
||||
BsMerPlatformNo merPlatform = merPlatformNoService.getCurrentPlatform(tableOrder.getMerId()); |
||||
if (merPlatform == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知交易渠道"); |
||||
} |
||||
Map<String, Object> param = new HashMap<>(); |
||||
param.put("payMode", TradeOrderPayModeEnum.WECHAT.getCode()); |
||||
param.put("payUserId", body.getString("payUserId")); |
||||
param.put("transType", "JSAPI"); |
||||
param.put("sub_appid", "wxff3cbb14f62d026d"); |
||||
|
||||
// 创建订单
|
||||
Map<String, Object> orderMap = tradeOrderService.createOrder(TradeOrderCreateTypeEnum.type4, tableOrder.getStoreId(), tableOrder.getOrderAmount(), null, null, null, param, request); |
||||
if (merPlatform.getPlatformType().equals(PlatformTypeEnum.type1.getNumber())) { |
||||
try { |
||||
Map<String, Object> order = laKaLaTradeService.preorder(MapUtils.getString(orderMap, "outTradeNo")); |
||||
System.out.println("返回参数:" + JSONObject.toJSONString(order)); |
||||
if (StringUtils.isNotBlank(MapUtils.getString(order, "order"))) { |
||||
// 设置支付状态
|
||||
tableOrder.setPayOrderNo(MapUtils.getString(orderMap, "outTradeNo")); |
||||
tableOrder.setPayStatus(MealTableOrderPayStatusEnum.status2.getNumber()); |
||||
mealTableOrderService.editData(tableOrder); |
||||
|
||||
|
||||
redisTemplate.delete(lockKey); |
||||
return ResponseMsgUtil.success(order); |
||||
} |
||||
} catch (Exception e) { |
||||
log.error("拉卡拉支付失败", e.getMessage()); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, e.getMessage()); |
||||
} |
||||
} else if (merPlatform.getPlatformType().equals(PlatformTypeEnum.type5.getNumber())) { |
||||
try { |
||||
Map<String, Object> order = tianQueTradeService.preorder(MapUtils.getString(orderMap, "outTradeNo")); |
||||
System.out.println("返回参数:" + JSONObject.toJSONString(order)); |
||||
if (StringUtils.isNotBlank(MapUtils.getString(order, "order"))) { |
||||
// 设置支付状态
|
||||
tableOrder.setPayOrderNo(MapUtils.getString(orderMap, "outTradeNo")); |
||||
tableOrder.setPayStatus(MealTableOrderPayStatusEnum.status2.getNumber()); |
||||
mealTableOrderService.editData(tableOrder); |
||||
|
||||
redisTemplate.delete(lockKey); |
||||
return ResponseMsgUtil.success(order); |
||||
} |
||||
} catch (Exception e) { |
||||
log.error("随行付支付失败", e.getMessage()); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, e.getMessage()); |
||||
} |
||||
} |
||||
|
||||
} else { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "小伙伴正在支付中..."); |
||||
} |
||||
} catch (BaseException baseException) { |
||||
redisTemplate.delete(lockKey); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, baseException.getErrorMsg()); |
||||
|
||||
} catch (Exception e) { |
||||
redisTemplate.delete(lockKey); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知错误"); |
||||
} |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "支付失败"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error(e.getMessage(), e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/cancelPay",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "取消支付") |
||||
public ResponseData cancelPay(@RequestBody JSONObject body) { |
||||
try { |
||||
if (body == null || StringUtils.isBlank(body.getString("orderNo"))) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
// 支付订单
|
||||
BsMealTableOrder tableOrder = mealTableOrderService.getTableOrderByOrderNo(body.getString("orderNo")); |
||||
if (tableOrder == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的订单号"); |
||||
} |
||||
if (tableOrder.getStatus().equals(MealTableOrderStatusEnum.status2.getNumber())) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "取消失败,订单已结账"); |
||||
} |
||||
tableOrder.setPayOrderNo(null); |
||||
tableOrder.setPayStatus(MealTableOrderPayStatusEnum.status1.getNumber()); |
||||
mealTableOrderService.editData(tableOrder); |
||||
|
||||
return ResponseMsgUtil.success("取消成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error(e.getMessage(), e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
|
@ -0,0 +1,198 @@ |
||||
package com.hfkj.config; |
||||
|
||||
import org.apache.commons.codec.digest.DigestUtils; |
||||
import org.apache.http.HttpEntity; |
||||
import org.apache.http.NameValuePair; |
||||
import org.apache.http.client.ClientProtocolException; |
||||
import org.apache.http.client.config.RequestConfig; |
||||
import org.apache.http.client.entity.UrlEncodedFormEntity; |
||||
import org.apache.http.client.methods.*; |
||||
import org.apache.http.client.utils.URLEncodedUtils; |
||||
import org.apache.http.impl.client.CloseableHttpClient; |
||||
import org.apache.http.impl.client.HttpClients; |
||||
import org.apache.http.message.BasicNameValuePair; |
||||
import org.apache.http.util.EntityUtils; |
||||
|
||||
import java.io.IOException; |
||||
import java.util.ArrayList; |
||||
import java.util.Arrays; |
||||
import java.util.HashMap; |
||||
|
||||
/** |
||||
* 商鹏打印机 |
||||
* @author hurui |
||||
*/ |
||||
public class SpPrinterConfig { |
||||
|
||||
public static final String baseUri = "https://open.spyun.net/v1/"; |
||||
|
||||
private String appid = "sp6284a57015d78"; |
||||
|
||||
private String appsecret = "2bdca1587ead21c0569e0ed1f82b19f6"; |
||||
|
||||
/* public SpPrinterConfig(String appid, String appsecret) { |
||||
this.appid = appid; |
||||
this.appsecret = appsecret; |
||||
}*/ |
||||
|
||||
// 添加打印机
|
||||
public String addPrinter(String sn, String pkey, String name) throws IOException { |
||||
ArrayList<NameValuePair> params = new ArrayList<>(); |
||||
params.add(new BasicNameValuePair("sn", sn)); |
||||
params.add(new BasicNameValuePair("pkey", pkey)); |
||||
params.add(new BasicNameValuePair("name", name)); |
||||
|
||||
return request("POST", "printer/add", params); |
||||
} |
||||
|
||||
// 删除打印机
|
||||
public String deletePrinter(String sn) throws IOException { |
||||
ArrayList<NameValuePair> params = new ArrayList<>(); |
||||
params.add(new BasicNameValuePair("sn", sn)); |
||||
|
||||
return request("DELETE", "printer/delete", params); |
||||
} |
||||
|
||||
// 修改打印机信息
|
||||
public String updatePrinter(String sn, String name) throws IOException { |
||||
ArrayList<NameValuePair> params = new ArrayList<>(); |
||||
params.add(new BasicNameValuePair("sn", sn)); |
||||
params.add(new BasicNameValuePair("name", name)); |
||||
|
||||
return request("PATCH", "printer/update", params); |
||||
} |
||||
|
||||
// 修改打印机参数
|
||||
public String updatePrinterSetting(String sn, int auto_cut, String voice) throws IOException { |
||||
ArrayList<NameValuePair> params = new ArrayList<>(); |
||||
params.add(new BasicNameValuePair("sn", sn)); |
||||
params.add(new BasicNameValuePair("auto_cut", String.valueOf(auto_cut))); |
||||
params.add(new BasicNameValuePair("voice", voice)); |
||||
|
||||
return request("PATCH", "printer/setting", params); |
||||
} |
||||
|
||||
// 获取打印机信息
|
||||
public String getPrinter(String sn) throws IOException { |
||||
ArrayList<NameValuePair> params = new ArrayList<>(); |
||||
params.add(new BasicNameValuePair("sn", sn)); |
||||
|
||||
return request("GET", "printer/info", params); |
||||
} |
||||
|
||||
// 打印订单
|
||||
public String print(String sn, String content, int times) throws IOException { |
||||
ArrayList<NameValuePair> params = new ArrayList<>(); |
||||
params.add(new BasicNameValuePair("sn", sn)); |
||||
params.add(new BasicNameValuePair("content", content)); |
||||
params.add(new BasicNameValuePair("times", String.valueOf(times))); |
||||
|
||||
return request("POST", "printer/print", params); |
||||
} |
||||
|
||||
// 清空待打印订单
|
||||
public String deletePrints(String sn) throws IOException { |
||||
ArrayList<NameValuePair> params = new ArrayList<>(); |
||||
params.add(new BasicNameValuePair("sn", sn)); |
||||
|
||||
return request("DELETE", "printer/cleansqs", params); |
||||
} |
||||
|
||||
// 查询打印订单状态
|
||||
public String getPrintsStatus(String id) throws IOException { |
||||
ArrayList<NameValuePair> params = new ArrayList<>(); |
||||
params.add(new BasicNameValuePair("id", id)); |
||||
|
||||
return request("GET", "printer/order/status", params); |
||||
} |
||||
|
||||
// 查询打印机历史打印订单数
|
||||
public String getPrintsOrders(String sn, String date) throws IOException { |
||||
ArrayList<NameValuePair> params = new ArrayList<>(); |
||||
params.add(new BasicNameValuePair("sn", sn)); |
||||
params.add(new BasicNameValuePair("date", date)); |
||||
|
||||
return request("GET", "printer/order/number", params); |
||||
} |
||||
|
||||
// 发送请求
|
||||
private String request(String method, String uri, ArrayList<NameValuePair> params) throws IOException { |
||||
RequestConfig requestConfig = RequestConfig.custom() |
||||
.setSocketTimeout(4000) //读取超时
|
||||
.setConnectTimeout(1000) //连接超时
|
||||
.build(); |
||||
|
||||
CloseableHttpClient httpClient = HttpClients.custom() |
||||
.setDefaultRequestConfig(requestConfig) |
||||
.build(); |
||||
|
||||
// 公共请求参数
|
||||
params.add(new BasicNameValuePair("appid", appid)); |
||||
params.add(new BasicNameValuePair("timestamp", String.valueOf(System.currentTimeMillis() / 1000))); |
||||
params.add(new BasicNameValuePair("sign", makeSign(params))); |
||||
|
||||
CloseableHttpResponse response = null; |
||||
String url = baseUri + uri; |
||||
if (method.equals("GET")) { |
||||
HttpGet request = new HttpGet(url + "?" + URLEncodedUtils.format(params, "utf-8")); |
||||
response = httpClient.execute(request); |
||||
} else if (method.equals("DELETE")) { |
||||
HttpDelete request = new HttpDelete(url + "?" + URLEncodedUtils.format(params, "utf-8")); |
||||
response = httpClient.execute(request); |
||||
} else if (method.equals("POST")) { |
||||
HttpPost request = new HttpPost(url); |
||||
request.setEntity(new UrlEncodedFormEntity(params,"utf-8")); |
||||
response = httpClient.execute(request); |
||||
} else if (method.equals("PATCH")) { |
||||
HttpPatch request = new HttpPatch(url); |
||||
request.setEntity(new UrlEncodedFormEntity(params,"utf-8")); |
||||
response = httpClient.execute(request); |
||||
} else if (method.equals("PUT")) { |
||||
HttpPut request = new HttpPut(url); |
||||
request.setEntity(new UrlEncodedFormEntity(params,"utf-8")); |
||||
response = httpClient.execute(request); |
||||
} |
||||
|
||||
if (response == null) { |
||||
throw new ClientProtocolException(); |
||||
} |
||||
|
||||
HttpEntity httpEntity = response.getEntity(); |
||||
if (httpEntity == null) { |
||||
throw new ClientProtocolException(); |
||||
} |
||||
|
||||
/* if (response.getStatusLine().getStatusCode() != 200) { |
||||
throw new ClientProtocolException(EntityUtils.toString(httpEntity)); |
||||
}*/ |
||||
|
||||
return EntityUtils.toString(httpEntity); |
||||
} |
||||
|
||||
// 创建签名
|
||||
public String makeSign(ArrayList<NameValuePair> params) { |
||||
int size = params.size(); |
||||
String[] keys = new String[params.size()]; |
||||
HashMap<String, String> values = new HashMap<>(); |
||||
for (int i = 0; i < size; i++) { |
||||
NameValuePair p = params.get(i); |
||||
keys[i] = p.getName(); |
||||
values.put(p.getName(), p.getValue()); |
||||
} |
||||
Arrays.sort(keys); |
||||
|
||||
String sign = ""; |
||||
for (int i = 0; i < keys.length; i++) { |
||||
String v = values.get(keys[i]); |
||||
if (!keys[i].equals("sign") && !keys[i].equals("appsecret") && !v.equals("")) { |
||||
if (i > 0) { |
||||
sign += "&"; |
||||
} |
||||
sign += keys[i] + "=" + v; |
||||
} |
||||
} |
||||
sign += "&appsecret=" + appsecret; |
||||
|
||||
return DigestUtils.md5Hex(sign).toUpperCase(); |
||||
} |
||||
} |
@ -0,0 +1,81 @@ |
||||
package com.hfkj.config; |
||||
|
||||
import com.hfkj.common.utils.DateUtil; |
||||
import com.hfkj.entity.BsMealTableOrder; |
||||
import com.hfkj.entity.BsMealTableOrderChild; |
||||
import com.hfkj.entity.BsMealTableOrderChildProduct; |
||||
import com.hfkj.entity.BsMealTableOrderProduct; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
|
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 商鹏打印机模板 |
||||
* @author hurui |
||||
*/ |
||||
public class SpPrinterTemplate { |
||||
|
||||
|
||||
/** |
||||
* 扫码点餐,点餐订单 |
||||
* @param mealTableOrder 交易订单 |
||||
* @param productList 产品列表 |
||||
* @return |
||||
*/ |
||||
public static String mealOrder(BsMealTableOrder mealTableOrder, BsMealTableOrderChild mealTableOrderChild,List<BsMealTableOrderChildProduct> productList) { |
||||
String str = "<C><L1>(点菜单)</L1></C>\n" + |
||||
"<C><L1>"+mealTableOrder.getTableName()+"</L1></C>\n" + |
||||
"订单号:"+mealTableOrder.getOrderNo() +"\n"+ |
||||
"用餐人数:"+mealTableOrder.getPeopleNum()+"人\n" + |
||||
"================================\n" + |
||||
"品名 数量\n" + |
||||
"================================\n"; |
||||
for (BsMealTableOrderChildProduct product : productList) { |
||||
str+=limitStr(13,product.getProductName())+" "+product.getProductNum()+"\n"; |
||||
} |
||||
str+="================================\n" + |
||||
"备注:" + (mealTableOrderChild.getRemark()==null?"":mealTableOrderChild.getRemark())+"\n" + |
||||
"打印时间:" + DateUtil.date2String(new Date(), DateUtil.Y_M_D_HMS) +"\n"; |
||||
return str; |
||||
} |
||||
|
||||
/** |
||||
* 加油站客户存根模板 |
||||
* @param mealTableOrder 交易订单 |
||||
* @param productList 产品列表 |
||||
* @return |
||||
*/ |
||||
public static String mealOrderBill(BsMealTableOrder mealTableOrder,List<BsMealTableOrderProduct> productList) { |
||||
String str = "<C><L1>"+mealTableOrder.getStoreName()+"</L1></C>\n" + |
||||
"<C><L1>"+mealTableOrder.getTableName()+"</L1></C>\n" + |
||||
"订单号:"+mealTableOrder.getOrderNo() +"\n"+ |
||||
"用餐人数:"+mealTableOrder.getPeopleNum()+"人\n" + |
||||
"开台时间:" + DateUtil.date2String(mealTableOrder.getCreateTime(), DateUtil.Y_M_D_HMS) +"\n"+ |
||||
"打印时间:" + DateUtil.date2String(new Date(), DateUtil.Y_M_D_HMS) +"\n"+ |
||||
"================================\n" + |
||||
"品名 数量 单价 金额\n" + |
||||
"================================\n"; |
||||
for (BsMealTableOrderProduct product : productList) { |
||||
str+=limitStr(8,product.getProductName())+" "+product.getProductNum()+" "+product.getProductPrice()+" "+product.getProductTotalPrice()+"\n"; |
||||
} |
||||
str+="================================\n" + |
||||
"<R>合计:"+mealTableOrder.getOrderAmount()+"元</R>\n" + |
||||
"--------------------------------\n" + |
||||
"<C>谢谢光临,欢迎下次惠顾!</C>\n"; |
||||
return str; |
||||
} |
||||
|
||||
private static String limitStr(int limit,String str) { |
||||
if (str.length() >= limit) { |
||||
return str.substring(0, limit-1); |
||||
} |
||||
// 补位长度
|
||||
int repairLength = limit - str.length(); |
||||
for (int i = 0; i < repairLength;i++) { |
||||
str+=" "; |
||||
} |
||||
return str; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,32 @@ |
||||
package com.hfkj.config; |
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService; |
||||
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; |
||||
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl; |
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
import javax.annotation.PostConstruct; |
||||
|
||||
@Configuration |
||||
public class WxMaConfig { |
||||
|
||||
private static WxMaService maService; |
||||
|
||||
public static WxMaService getMaService() { |
||||
if (maService == null) { |
||||
throw new IllegalArgumentException(String.format("未找到对应的配置,请核实!")); |
||||
} |
||||
|
||||
return maService; |
||||
} |
||||
|
||||
@PostConstruct |
||||
public void init() { |
||||
WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl(); |
||||
config.setAppid(CommonSysConst.getSysConfig().getWechat_ma_appid()); |
||||
config.setSecret(CommonSysConst.getSysConfig().getWechat_ma_secret()); |
||||
maService = new WxMaServiceImpl(); |
||||
maService.setWxMaConfig(config); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,53 @@ |
||||
package com.hfkj.service.meal.impl; |
||||
|
||||
import com.hfkj.dao.BsMealTableOrderChildMapper; |
||||
import com.hfkj.dao.BsMealTableOrderChildProductMapper; |
||||
import com.hfkj.entity.BsMealTableOrderChild; |
||||
import com.hfkj.entity.BsMealTableOrderChildProduct; |
||||
import com.hfkj.entity.BsMealTableOrderChildProductExample; |
||||
import com.hfkj.service.meal.BsMealTableOrderChildProductService; |
||||
import org.apache.commons.collections4.MapUtils; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @className: BsMealTableOrderChildProductServiceImpl |
||||
* @author: HuRui |
||||
* @date: 2023/12/11 |
||||
**/ |
||||
@Service("mealTableOrderChildProductService") |
||||
public class BsMealTableOrderChildProductServiceImpl implements BsMealTableOrderChildProductService { |
||||
|
||||
@Resource |
||||
private BsMealTableOrderChildProductMapper mealTableOrderChildProductMapper; |
||||
|
||||
@Override |
||||
public void editData(BsMealTableOrderChildProduct data) { |
||||
if (data.getId() == null) { |
||||
data.setCreateTime(new Date()); |
||||
data.setUpdateTime(new Date()); |
||||
mealTableOrderChildProductMapper.insert(data); |
||||
} else { |
||||
data.setUpdateTime(new Date()); |
||||
mealTableOrderChildProductMapper.updateByPrimaryKeySelective(data); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public List<BsMealTableOrderChildProduct> getProductList(Map<String, Object> param) { |
||||
BsMealTableOrderChildProductExample example = new BsMealTableOrderChildProductExample(); |
||||
BsMealTableOrderChildProductExample.Criteria criteria = example.createCriteria(); |
||||
|
||||
if (StringUtils.isNotBlank(MapUtils.getString(param, "childOrderNo"))) { |
||||
criteria.andChildOrderNoEqualTo(MapUtils.getString(param, "childOrderNo")); |
||||
} |
||||
|
||||
example.setOrderByClause("create_time desc"); |
||||
return mealTableOrderChildProductMapper.selectByExample(example); |
||||
} |
||||
} |
@ -0,0 +1,51 @@ |
||||
package com.hfkj.sysenum; |
||||
|
||||
import java.util.Objects; |
||||
|
||||
/** |
||||
* @className: MealTableOrderStatus |
||||
* @author: HuRui |
||||
* @date: 2023/11/30 |
||||
**/ |
||||
public enum MealTableOrderPayStatusEnum { |
||||
|
||||
status1(1, "待支付"), |
||||
status2(2, "支付中"), |
||||
status3(3, "已支付"), |
||||
; |
||||
|
||||
private Integer number; |
||||
|
||||
private String name; |
||||
|
||||
MealTableOrderPayStatusEnum(int number, String name) { |
||||
this.number = number; |
||||
this.name = name; |
||||
} |
||||
|
||||
public static MealTableOrderPayStatusEnum getDataByNumber(Integer number) { |
||||
for (MealTableOrderPayStatusEnum ele : values()) { |
||||
if (Objects.equals(number,ele.getNumber())) { |
||||
return ele; |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
|
||||
public Integer getNumber() { |
||||
return number; |
||||
} |
||||
|
||||
public void setNumber(Integer number) { |
||||
this.number = number; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
} |
Loading…
Reference in new issue