提交代码

dev-discount
胡锐 3 years ago
parent aca391e3a8
commit 2ec4e5ef28
  1. 30
      hai-bweb/src/main/java/com/bweb/config/msg/MerStoreAccountChgHandler.java
  2. 127
      hai-bweb/src/main/java/com/bweb/controller/HighGasController.java
  3. 4
      hai-bweb/src/main/java/com/bweb/controller/HighOrderController.java
  4. 2
      hai-cweb/src/main/java/com/cweb/controller/HighTestController.java
  5. 82
      hai-service/src/main/java/com/hai/config/BaiduVoiceService.java
  6. 198
      hai-service/src/main/java/com/hai/config/SpPrinterConfig.java
  7. 105
      hai-service/src/main/java/com/hai/config/SpPrinterTemplate.java
  8. 37
      hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java
  9. 1
      hai-service/src/main/java/com/hai/enum_type/MerStoreAmountSourceTypeEnum.java
  10. 45
      hai-service/src/main/java/com/hai/model/GasOrderModel.java
  11. 13
      hai-service/src/main/java/com/hai/service/impl/HighMerchantStoreServiceImpl.java
  12. 54
      hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java

@ -1,8 +1,10 @@
package com.bweb.config.msg;
import com.hai.enum_type.MerStoreAmountTypeEnum;
import com.hai.msg.entity.MsgTopic;
import com.hai.service.HighMerchantStoreAccountService;
import com.hai.service.HighOrderService;
import org.apache.commons.collections4.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -11,6 +13,9 @@ import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
@Component
public class MerStoreAccountChgHandler {
@ -39,6 +44,31 @@ public class MerStoreAccountChgHandler {
//处理消息
logger.info("消息通道:"+o);
Map<String, Object> param = (Map<String, Object>) o;
if (MapUtils.getInteger(param, "businessType").equals(MerStoreAmountTypeEnum.type1.getType())) {
Map<String, Object> otherParam = new HashMap<>();
otherParam.put("sourceType", MapUtils.getString(param, "sourceType"));
otherParam.put("sourceId", MapUtils.getString(param, "sourceId"));
otherParam.put("sourceContent", MapUtils.getString(param, "sourceContent"));
merchantStoreAccountService.recharge(
MapUtils.getLong(param, "storeId"),
new BigDecimal(MapUtils.getString(param, "price")),
otherParam );
}
if (MapUtils.getInteger(param, "businessType").equals(MerStoreAmountTypeEnum.type2.getType())) {
Map<String, Object> otherParam = new HashMap<>();
otherParam.put("sourceType", MapUtils.getString(param, "sourceType"));
otherParam.put("sourceId", MapUtils.getString(param, "sourceId"));
otherParam.put("sourceContent", MapUtils.getString(param, "sourceContent"));
merchantStoreAccountService.consume(
MapUtils.getLong(param, "storeId"),
new BigDecimal(MapUtils.getString(param, "price")),
otherParam);
}
} else {
Thread.sleep(1000);

@ -6,26 +6,34 @@ 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.SessionObject;
import com.hai.common.security.UserCenter;
import com.hai.common.utils.CoordCommonUtil;
import com.hai.common.utils.PageUtil;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.config.HuiLianTongUnionCardConfig;
import com.hai.config.TuanYouConfig;
import com.hai.entity.HighGasDiscountOilPrice;
import com.hai.config.WxOrderConfig;
import com.hai.entity.HighChildOrder;
import com.hai.entity.HighGasOilPrice;
import com.hai.entity.HighMerchantStore;
import com.hai.entity.HighOrder;
import com.hai.enum_type.GasOilPriceStatusEnum;
import com.hai.enum_type.MerStoreAmountSourceTypeEnum;
import com.hai.enum_type.MerStoreAmountTypeEnum;
import com.hai.enum_type.OrderPayTypeEnum;
import com.hai.model.HighMerchantStoreModel;
import com.hai.model.OrderRefundModel;
import com.hai.model.ResponseData;
import com.hai.model.UserInfoModel;
import com.hai.service.HighGasOilPriceService;
import com.hai.service.HighOrderService;
import com.hai.msg.entity.MsgTopic;
import com.hai.service.*;
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.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
@ -46,9 +54,21 @@ public class HighGasController {
@Resource
private HighOrderService highOrderService;
@Resource
private HighMerchantStoreService merchantStoreService;
@Resource
private HighUserService highUserService;
@Resource
private HighOilCardService oilCardService;
@Autowired
private UserCenter userCenter;
@Resource
private RedisTemplate redisTemplate;
@RequestMapping(value="/getGasStatistical",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "查询油站统计")
@ -85,7 +105,7 @@ public class HighGasController {
@ResponseBody
@ApiOperation(value = "查询油站订单列表")
public ResponseData getGasOrderList(@RequestParam(name = "orderNo", required = false) String orderNo,
@RequestParam(name = "status", required = false) Integer status, // 1:已支付 2:退款
@RequestParam(name = "status", required = false) Integer status,
@RequestParam(name = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize) {
try {
@ -98,10 +118,10 @@ public class HighGasController {
param.put("storeId", userInfoModel.getMerchantStore().getId());
param.put("orderNo", orderNo);
if (status != null && status.equals(1)) {
param.put("status", "2,3,6,7");
} else if (status != null && status.equals(2)) {
param.put("status", "4");
if (status == null) {
param.put("status", "2,3,4,6,7");
} else {
param.put("status", status);
}
PageHelper.startPage(pageNum, pageSize);
@ -277,20 +297,87 @@ public class HighGasController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息");
}
// 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 6.退款中 7.拒绝退款
if (order.getOrderStatus() != 2) {
log.error("HighOrderController --> refuelingOrderRefund() error!", "提交退款审核失败,订单不处于已支付");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "提交退款审核失败,订单不处于已支付");
if (order.getOrderStatus() != 3) {
log.error("HighOrderController --> refuelingOrderRefund() error!", "退款失败,订单状态准许退款");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败,订单状态准许退款");
}
JSONObject object = TuanYouConfig.refuelingOrderRefund(order.getMemPhone(), order.getOrderNo(), body.getString("refundContent"));
if (object == null || !object.getString("code").equals("200")) {
log.error("HighOrderController --> refuelingOrderRefund() error!", "提交退款审核失败," + object.getString("message"));
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "提交退款审核失败," + object.getString("message"));
}
for (HighChildOrder childOrder : order.getHighChildOrderList()) {
if (!childOrder.getGoodsType().equals(3)) {
log.error("HighOrderController --> refuelingOrderRefund() error!", "退款失败,不属于加油站订单");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败,不属于加油站订单");
}
// 查询加油站
HighMerchantStoreModel store = merchantStoreService.getMerchantStoreById(childOrder.getGoodsId());
if (store == null) {
log.error("HighOrderController --> refuelingOrderRefund() error!", "退款失败,未找到加油站信息");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败,未找到加油站信息");
}
order.setOrderStatus(6);
highOrderService.updateOrderDetail(order);
return ResponseMsgUtil.success("退款审核中");
// 来源类型 1:平台自建 2:团油
if (store.getSourceType().equals(1)) {
if (order.getPayType() == 2) {
OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(order.getPaySerialNo(), order.getPayRealPrice(), order.getPayRealPrice());
if(orderRefundModel.getResult_code().equals("SUCCESS")) {
order.setOrderStatus(4);
order.setRefundTime(new Date());
order.setRefundPrice(order.getPayRealPrice());
highOrderService.updateOrderDetail(order);
}
} else if (order.getPayType() == 3){
// 积分退款
highUserService.goldHandle(order.getMemId(), order.getPayGold(),1, 2, order.getId());
order.setOrderStatus(4);
order.setRefundTime(new Date());
order.setRefundPrice(order.getPayRealPrice());
highOrderService.updateOrderDetail(order);
} else if (order.getPayType() == 4) {
String refundOrderNo = String.valueOf(System.currentTimeMillis());
JSONObject refund = HuiLianTongUnionCardConfig.refund(refundOrderNo, order.getPaySerialNo());
if(!refund.getString("respCode").equals("0000")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR,refund.getString("respMessage"));
}
JSONObject consumptionResult = HuiLianTongUnionCardConfig.resolveResponse(refund.getString("data"));
if (consumptionResult.getBoolean("success") != true) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "交易失败!"+consumptionResult.getString("message"));
}
order.setOrderStatus(4);
order.setRefundTime(new Date());
order.setRefundPrice(order.getPayRealPrice());
highOrderService.updateOrderDetail(order);
} else if (order.getPayType().equals(OrderPayTypeEnum.type7.getType())) {
// 油卡退款
oilCardService.refund(order.getOrderNo());
}
Map<String, Object> pushParam = new HashMap<>();
pushParam.put("businessType", MerStoreAmountTypeEnum.type1.getType());
pushParam.put("storeId", store.getId());
pushParam.put("price", order.getTotalPrice());
pushParam.put("sourceType", MerStoreAmountSourceTypeEnum.type3.getType());
pushParam.put("sourceId", order.getId());
pushParam.put("sourceContent", "订单号:" + order.getOrderNo() + ",退款金额:¥" + order.getTotalPrice());
// 退款到预存余额
this.redisTemplate.boundListOps(MsgTopic.MerStoreAccount.getName()).leftPush(pushParam);
order.setOrderStatus(4);
order.setRefundTime(new Date());
order.setRefundContent(body.getString("refundContent"));
highOrderService.updateOrderDetail(order);
} else if (store.getSourceType().equals(2)) {
JSONObject object = TuanYouConfig.refuelingOrderRefund(order.getMemPhone(), order.getOrderNo(), body.getString("refundContent"));
if (object == null || !object.getString("code").equals("200")) {
log.error("HighOrderController --> refuelingOrderRefund() error!", "提交退款审核失败," + object.getString("message"));
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "提交退款审核失败," + object.getString("message"));
}
order.setOrderStatus(6);
highOrderService.updateOrderDetail(order);
}
}
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("HighGasController -> refuelingOrderRefund() error!",e);

@ -203,8 +203,8 @@ public class HighOrderController {
} else if (userInfoModel.getSecUser().getObjectType() == 2) {
map.put("merchantId", userInfoModel.getMerchant().getId());
} else if (userInfoModel.getSecUser().getObjectType() == 3) {
map.put("merchantId", userInfoModel.getMerchant().getId());
} else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, "");
}
map.put("orderNo", orderNo);

File diff suppressed because one or more lines are too long

@ -0,0 +1,82 @@
package com.hai.config;
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.HttpsUtils;
import com.hai.common.utils.RedisUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.*;
/**
* 百度AI开放平台语音合成
* @author hurui
*/
@Component
public class BaiduVoiceService {
@Resource
private RedisUtil redisUtil;
/**
* 获取token
* @return
* @throws Exception
*/
public String getToken() {
Object token = redisUtil.get("baidu_voice_token");
if (token != null) {
return token.toString();
}
Map<String, Object> map = new HashMap<>();
map.put("grant_type", "client_credentials");
map.put("client_id", "21NEfkbyDiXVZ3kf3vI8rwOG");
map.put("client_secret", "EyN2X1oBDERL7dwMX2WIqoZnsdtvadCC");
// 获取token
JSONObject tokenObject = HttpsUtils.doGet("https://aip.baidubce.com/oauth/2.0/token", map);
if (StringUtils.isNotBlank(tokenObject.getString("access_token"))) {
redisUtil.set("baidu_voice_token", tokenObject.getString("access_token"), tokenObject.getLong("expires_in"));
return tokenObject.getString("access_token");
}
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取token失败");
}
/**
* 文本转换语音
* @param text 文本
* @return
* @throws Exception
*/
public String text2audio(String text) {
Map<String, Object> param = new HashMap<>();
param.put("tok", this.getToken());
param.put("tex", text);
param.put("cuid", System.currentTimeMillis()+"");
param.put("ctp", 1);
param.put("lan", "zh");
param.put("spd", 5);
param.put("pit", 5);
param.put("vol", 8);
param.put("per", 5118);
param.put("aue", 3);
String apiUrl = "http://tsn.baidu.com/text2audio";
StringBuffer paramStr = new StringBuffer();
int i = 0;
for (String key : param.keySet()) {
if (i == 0) {
paramStr.append("?");
} else {
paramStr.append("&");
paramStr.append(key).append("=").append(param.get(key));
}
i++;
}
return apiUrl + paramStr;
}
}

@ -0,0 +1,198 @@
package com.hai.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,105 @@
package com.hai.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 SpPrinterTemplate {
/**
* 加油站收银员存根模板
* @param gasName 油站名称
* @param orderNo 订单号
* @param payTime 支付时间
* @param source 来源
* @param gunNo 抢号
* @param oilNo 油号
* @param oilLiters 升数
* @param orderPrice 加油金额
* @return
*/
public static String oilCashierStubTemp(String gasName,
String orderNo,
String payTime,
String source,
String gunNo,
String oilNo,
String oilLiters,
String orderPrice) {
String str = "<C><B>" + gasName + "</B></C> <BR> " +
"<C>(收银员存根)</C> <BR>" +
"------------------------------<BR>" +
"流水:" + orderNo + "<BR>" +
"------------------------------<BR>" +
"时间:" + payTime + "<BR>" +
"来源:" + source + "<BR>" +
"油枪:"+ gunNo + "号<BR>" +
"油品:" + oilNo + "#<BR>" +
"升数:" + oilLiters +"升<BR>" +
"实际加油升数以油站加油机为准!<BR>" +
"------------------------------<BR>" +
"<L2>加油金额</L2><BR>" +
"<L2>¥" + orderPrice + "元</L2><BR>" +
"------------------------------<BR>" +
"<C>来"嗨森逛“;开心又省钱</C>";
return str;
}
/**
* 加油站客户存根模板
* @param gasName 油站名称
* @param orderNo 订单号
* @param payTime 支付时间
* @param source 来源
* @param gunNo 抢号
* @param oilNo 油号
* @param oilLiters 升数
* @param orderPrice 加油金额
* @return
*/
public static String oilClientStubTemp(String gasName,
String orderNo,
String payTime,
String source,
String gunNo,
String oilNo,
String oilLiters,
String orderPrice) {
String str = "<C><B>" + gasName + "</B></C> <BR> " +
"<C>(客户存根)</C> <BR>" +
"------------------------------<BR>" +
"流水:" + orderNo + "<BR>" +
"------------------------------<BR>" +
"时间:" + payTime + "<BR>" +
"来源:" + source + "<BR>" +
"油枪:"+ gunNo + "号<BR>" +
"油品:" + oilNo + "#<BR>" +
"升数:" + oilLiters +"升<BR>" +
"实际加油升数以油站加油机为准!<BR>" +
"------------------------------<BR>" +
"<L2>加油金额</L2><BR>" +
"<L2>¥" + orderPrice + "元</L2><BR>" +
"------------------------------<BR>" +
"<C>来"嗨森逛“;开心又省钱</C>";
return str;
}
}

@ -52,7 +52,7 @@ public interface HighOrderMapperExt {
"from high_coupon_code cc join high_child_order co on cc.child_order_id = co.id) cocc on cocc.order_id = od.id ",
") a on coupon.id = a.coupon_id ",
"where ",
"1=1 ",
"1 = 1 ",
"<if test='map.companyId != null'> AND company_id = #{map.companyId} </if>",
"<if test='map.merchantId != null'> AND merchant_id = #{map.merchantId} </if>",
"<if test='map.storeId != null'> AND store_id = #{map.storeId} </if>",
@ -1080,4 +1080,39 @@ public interface HighOrderMapperExt {
" where a.order_id = b.id and goods_type = 3 and goods_id = #{storeId} and b.order_status in (${storeId}) " +
" and to_days(pay_time) = to_days(now())"})
Map<String, Object> selectGasTheDayOrderCount(@Param("storeId") Long storeId, @Param("status") String status);
@Select({
"<script> " +
" select " +
" b.order_no orderNo," +
" a.gas_order_no gasOrderNo," +
" b.pay_type payType," +
" b.total_price totalPrice," +
" b.deduction_price deductionPrice," +
" b.pay_real_price payRealPrice," +
" b.order_status status," +
" a.goods_name gasName," +
" (select address from high_merchant_store where id = a.goods_id) gasAddress," +
" (select store_logo from high_merchant_store where id = a.goods_id) gasLogo," +
" a.gas_oil_no gasOilNo," +
" a.gas_gun_no gasGunNo," +
" a.gas_price_gun gasPriceGun," +
" a.gas_oil_liters gasOilLiters," +
" a.gas_discount gasDiscount," +
" a.gas_oil_subsidy gasOilSubsidy," +
" a.gas_liters_preferences gasLitersPreferences," +
" a.gas_price_preferences gasPricePreferences," +
" b.create_time createTime," +
" b.pay_time payTime," +
" b.refund_time refundTime" +
" from high_child_order a,high_order b " +
" where a.order_id = b.id " +
" and goods_type = 3 " +
"<if test='param.storeId != null'> and goods_id = #{param.storeId} </if>" +
"<if test='param.status != null'> and b.order_status in (${param.status})</if>" +
"<if test='param.orderNo != null'> and b.order_no LIKE concat('%', #{param.orderNo}, '%')</if>" +
" ORDER BY create_time desc" +
"</script>"
})
List<GasOrderModel> selectGasStoreOrderList(@Param("param") Map<String, Object> param);
}

@ -7,6 +7,7 @@ package com.hai.enum_type;
public enum MerStoreAmountSourceTypeEnum {
type1(1, "金额充值"),
type2(2, "订单消费"),
type3(3, "订单退款"),
;
private Integer type;

@ -16,11 +16,16 @@ public class GasOrderModel {
private BigDecimal deductionPrice;
private BigDecimal payRealPrice;
private Integer status;
private String gasLogo;
private String gasName;
private String gasAddress;
private String gasOilNo;
private String gasGunNo;
private String gasOilLiters;
private String gasDiscount;
private String gasOilSubsidy;
private String gasLitersPreferences;
private String gasPricePreferences;
private String gasPriceGun;
private Date createTime;
private Date payTime;
@ -82,6 +87,14 @@ public class GasOrderModel {
this.status = status;
}
public String getGasLogo() {
return gasLogo;
}
public void setGasLogo(String gasLogo) {
this.gasLogo = gasLogo;
}
public String getGasName() {
return gasName;
}
@ -122,6 +135,38 @@ public class GasOrderModel {
this.gasOilLiters = gasOilLiters;
}
public String getGasDiscount() {
return gasDiscount;
}
public void setGasDiscount(String gasDiscount) {
this.gasDiscount = gasDiscount;
}
public String getGasOilSubsidy() {
return gasOilSubsidy;
}
public void setGasOilSubsidy(String gasOilSubsidy) {
this.gasOilSubsidy = gasOilSubsidy;
}
public String getGasLitersPreferences() {
return gasLitersPreferences;
}
public void setGasLitersPreferences(String gasLitersPreferences) {
this.gasLitersPreferences = gasLitersPreferences;
}
public String getGasPricePreferences() {
return gasPricePreferences;
}
public void setGasPricePreferences(String gasPricePreferences) {
this.gasPricePreferences = gasPricePreferences;
}
public String getGasPriceGun() {
return gasPriceGun;
}

@ -1,6 +1,7 @@
package com.hai.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hai.common.exception.ErrorCode;
@ -8,6 +9,7 @@ import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.utils.CoordCommonUtil;
import com.hai.common.utils.MD5Util;
import com.hai.config.SpPrinterConfig;
import com.hai.dao.HighMerchantStoreMapper;
import com.hai.entity.HighMerchantStore;
import com.hai.entity.HighMerchantStoreExample;
@ -59,6 +61,17 @@ public class HighMerchantStoreServiceImpl implements HighMerchantStoreService {
highMerchantStore.getSecUser().setCreateTime(new Date());
highMerchantStore.getSecUser().setUpdateTime(new Date());
secUserService.addUser(highMerchantStore.getSecUser());
// 绑定设备
if (StringUtils.isBlank(highMerchantStore.getDeviceKey())
&& StringUtils.isBlank(highMerchantStore.getDeviceSn())
&& StringUtils.isBlank(highMerchantStore.getDeviceName())) {
SpPrinterConfig sp = new SpPrinterConfig();
JSONObject jsonObject = JSONObject.parseObject(sp.addPrinter(highMerchantStore.getDeviceSn(), highMerchantStore.getDeviceKey(), highMerchantStore.getDeviceName()));
if (!jsonObject.getLong("errorcode").equals(0)) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOF_FOUND, jsonObject.getString("errormsg"));
}
}
}
@Override

@ -357,17 +357,48 @@ public class HighOrderServiceImpl implements HighOrderService {
if (store.getSourceType().equals(1)) {
// 预存类型 0:非预存 1:预存门店
if (store.getPrestoreType() != null && store.getPrestoreType().equals(1)) {
Map<String, Object> otherParam = new HashMap<>();
otherParam.put("sourceType", MerStoreAmountSourceTypeEnum.type2.getType());
otherParam.put("sourceId", highOrder.getId());
otherParam.put("sourceContent", "订单号:" + highOrder.getOrderNo() + ",加油金额:¥" + highOrder.getTotalPrice());
// merchantStoreAccountService.consume(store.getId(), order.getTotalPrice(), otherParam);
Map<String, Object> pushParam = new HashMap<>();
pushParam.put("businessType", MerStoreAmountTypeEnum.type2.getType());
pushParam.put("object", otherParam);
pushParam.put("storeId", highChildOrder.getGoodsId());
pushParam.put("price", highOrder.getTotalPrice());
pushParam.put("sourceType", MerStoreAmountSourceTypeEnum.type2.getType());
pushParam.put("sourceId", highOrder.getId());
pushParam.put("sourceContent", "订单号:" + highOrder.getOrderNo() + ",加油金额:¥" + highOrder.getTotalPrice());
// 扣预存款
this.redisTemplate.boundListOps(MsgTopic.MerStoreAccount.getName()).leftPush(pushParam);
}
new Thread(() -> {
try {
SpPrinterConfig sp = new SpPrinterConfig();
sp.print(store.getDeviceSn(),
SpPrinterTemplate.oilCashierStubTemp(
highChildOrder.getGoodsName(),
highOrder.getOrderNo(),
DateUtil.date2String(highOrder.getPayTime(), "yyyy-MM-dd HH:mm:ss"),
"嗨森逛",
highChildOrder.getGasGunNo(),
highChildOrder.getGasOilNo(),
highChildOrder.getGasOilLiters().toString(),
highOrder.getTotalPrice().toString()
), 1);
sp.print(store.getDeviceSn(),
SpPrinterTemplate.oilClientStubTemp(
highChildOrder.getGoodsName(),
highOrder.getOrderNo(),
DateUtil.date2String(highOrder.getPayTime(), "yyyy-MM-dd HH:mm:ss"),
"嗨森逛",
highChildOrder.getGasGunNo(),
highChildOrder.getGasOilNo(),
highChildOrder.getGasOilLiters().toString(),
highOrder.getTotalPrice().toString()
), 1);
} catch (Exception e) {
e.printStackTrace();
}
}).start();
} else if (store.getSourceType().equals(2)) {
// 推送团油订单
Map<String,Object> paramMap = new HashMap<>();
@ -1084,7 +1115,6 @@ public class HighOrderServiceImpl implements HighOrderService {
@Override
public List<HighOrderData> getOrderBList(Map<String, Object> map) {
return highOrderMapperExt.selectOrderDataList(map);
}
@ -1564,11 +1594,17 @@ public class HighOrderServiceImpl implements HighOrderService {
@Override
public List<GasOrderModel> getGasOrderList(Map<String, Object> param) {
return null;
return highOrderMapperExt.selectGasStoreOrderList(param);
}
@Override
public GasOrderModel getGasOrderDetail(String orderNo) {
Map<String, Object> param = new HashMap<>();
param.put("orderNo", orderNo);
List<GasOrderModel> list = highOrderMapperExt.selectGasStoreOrderList(param);
if (list.size() > 0) {
return list.get(0);
}
return null;
}

Loading…
Cancel
Save