Commit 87485666 by 张新旗

代码提交

parent f6d7ceb5
package com.ruoyi.web.controller.coffee;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.domain.Order;
import com.ruoyi.system.service.impl.AppServiceImpl;
import com.ruoyi.system.service.impl.OrderServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -10,10 +14,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@RestController
@RequestMapping("/app")
public class AppController {
public class AppController extends BaseController {
@Autowired
private TokenService tokenService;
@Autowired
......@@ -24,13 +29,15 @@ public class AppController {
@RequestMapping("/getMyOrder")
public AjaxResult getMyOrder(HttpServletRequest request){
public TableDataInfo getMyOrder(HttpServletRequest request){
LoginUser loginUser = tokenService.getLoginUser(request);
if(loginUser ==null){
return AjaxResult.error("请先登录");
throw new ServiceException("请先登录");
}
String openId = loginUser.getOpenId();
return AjaxResult.success(orderService.getMyOrder(openId));
startPage();
List<Order> myOrder = orderService.getMyOrder(openId);
return getDataTable(myOrder);
}
@RequestMapping("/refundOrder")
public AjaxResult refundOrder(String orderId){
......
......@@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
......@@ -41,7 +42,7 @@ public class ApplicationController {
String key = machineCode+"_"+id;
stringRedisTemplate.opsForValue().set(key, body);
stringRedisTemplate.expire(id,1, TimeUnit.HOURS);
return AjaxResult.success(id);
return AjaxResult.success("处理成功",key);
}
@RequestMapping("/getData")
public AjaxResult getApplicationData(String key){
......@@ -54,12 +55,18 @@ public class ApplicationController {
map.put("type","1");
map.put("code","200");
jiGuangPushService.push(keys[0],map);
return AjaxResult.success(s);
return AjaxResult.success("处理成功",s);
}
@RequestMapping("/jgRegister")
public AjaxResult jgRegister(String machineCode,String registerId){
public AjaxResult jgRegister(@RequestParam String machineCode,@RequestParam String registerId){
Machine machine = new Machine();
machine.setId(machineCode);
List<Machine> machines = machineService.selectMachineList(machine);
if(machines==null ||machines.isEmpty()){
return AjaxResult.error("该机器未绑定店铺,请先绑定店铺");
}
machine.setRegister(registerId);
return AjaxResult.success(machineService.updateMachine(machine));
}
......
......@@ -2,31 +2,48 @@ package com.ruoyi.web.controller.coffee;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.vo.ResultVo;
import com.ruoyi.system.service.impl.MachineApiServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/v1")
@Slf4j
public class MachineApiController {
@Autowired
private MachineApiServiceImpl machineApiService;
@PostMapping("/down/material/update")
public AjaxResult shopGoodsUpdate(@RequestBody String body){
public ResultVo shopGoodsUpdate(@RequestBody String body){
log.info("/down/material/update 请求内容为 【{}】",body);
JSONObject jsonObject = JSONObject.parseObject(body);
return AjaxResult.success(machineApiService.shopGoodsUpdate(jsonObject));
return ResultVo.success(machineApiService.shopGoodsUpdate(jsonObject));
}
@PostMapping("/down/order/update")
public AjaxResult updateOrder(@RequestBody String body){
public ResultVo updateOrder(@RequestBody String body){
log.info("/down/order/update 请求内容为 【{}】",body);
JSONObject jsonObject = JSONObject.parseObject(body);
return AjaxResult.success(machineApiService.updateOrder(jsonObject));
return ResultVo.success(machineApiService.updateOrder(jsonObject));
}
@PostMapping("/down/robot/status")
public AjaxResult robotUpdate(@RequestBody String body){
return null;
public ResultVo robotUpdate(@RequestBody String body){
log.info("/down/robot/status 请求内容为 【{}】",body);
JSONObject jsonObject = JSONObject.parseObject(body);
try{
return ResultVo.success(machineApiService.robotUpdate(jsonObject));
}catch (Exception e){
return ResultVo.error(e.getMessage());
}
}
@GetMapping("/testOrder")
public void testOrder(String orderId){
machineApiService.testOrder(orderId);
}
@GetMapping("/testOrderUpdate")
public void testOrderUpdate(String orderId){
machineApiService.testOrderUpdate(orderId);
}
}
......@@ -77,7 +77,7 @@ public class MaterialController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('system:material:remove')")
@Log(title = "原料", businessType = BusinessType.DELETE)
@DeleteMapping("/{id}")
@RequestMapping("/remove")
public AjaxResult remove(@RequestParam String id)
{
return materialService.deleteMaterialById(id);
......
......@@ -88,7 +88,7 @@ public class OrderController extends BaseController
return ajaxResult;
}
int amount = order.getAmount().movePointRight(2).intValue();
Map payInfo = weixinService.payment(amount,order.getOrderDetails().get(0).getGoodsName(),order.getOrderNo(),loginUser.getOpenId());
Map payInfo = weixinService.pay(request, "hooloo", order.getOrderNo(), order.getUserId(), amount);
if(payInfo !=null){
return AjaxResult.success(payInfo);
}else{
......
......@@ -58,33 +58,62 @@ public class OrderRefundController extends BaseController
/**
* 新增订单退款
*/
@PreAuthorize("@ss.hasPermi('system:refund:add')")
@Log(title = "订单退款", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody OrderRefund orderRefund)
{
return toAjax(orderRefundService.insertOrderRefund(orderRefund));
}
AjaxResult ajaxResult = orderRefundService.insertOrderRefund(orderRefund);
Object obejct = ajaxResult.get(AjaxResult.DATA_TAG);
if(obejct!=null && obejct instanceof OrderRefund){
/**
* 修改订单退款
*/
@PreAuthorize("@ss.hasPermi('system:refund:edit')")
@Log(title = "订单退款", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody OrderRefund orderRefund)
{
return toAjax(orderRefundService.updateOrderRefund(orderRefund));
}
/**
* 删除订单退款
*/
@PreAuthorize("@ss.hasPermi('system:refund:remove')")
@Log(title = "订单退款", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids)
{
return toAjax(orderRefundService.deleteOrderRefundByIds(ids));
}
return ajaxResult;
}
// public void refund(HttpServletRequest request,
// String openid,
// int activityid,
// int memberid) throws Exception {
// //先将订单信息查出来 这里的订单就是上边说的支付订单,我的是通过openid和一个activityid查出来的,自己可根据业务逻辑修改。
// QueryWrapper<Wxpaynotifyvo> wxPayNotifyVOQueryWrapper = new QueryWrapper<>();
// wxPayNotifyVOQueryWrapper.eq("openid", openid);
// wxPayNotifyVOQueryWrapper.eq("activityid", activityid);
// Wxpaynotifyvo wxPayNotifyVO = this.wxPayService.getBaseMapper().selectOne(wxPayNotifyVOQueryWrapper);
// //构建参数
// Map<String, String> dataMap = new HashMap<>();
// //小程序ID
// dataMap.put("appid", WechatConstant.APPID);
// //商户号
// dataMap.put("mch_id", WechatConstant.MCH_ID);
// //随机字符串
// dataMap.put("nonce_str", UUID.randomUUID().toString().replaceAll("-", ""));
// //微信订单号
// dataMap.put("transaction_id", wxPayNotifyVO.getTransactionid());
// //商户退款单号
// Date now = new Date();
// SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");//可以方便地修改日期格式
// String outRefundNo = "NO" + dateFormat.format(now);
// dataMap.put("out_refund_no", outRefundNo);
// //订单金额
// dataMap.put("total_fee", wxPayNotifyVO.getTotalfee());
//
// //退款金额
// dataMap.put("refund_fee", wxPayNotifyVO.getTotalfee());
// //商户证书密钥,生成签名
// String sign = WXPayUtil.generateSignature(dataMap, WechatConstant.KEY);
// dataMap.put("sign", sign);
// //这个是将报名表里的数据删除
// int i = applymanService.deleteApplyman(openid, activityid, memberid);
// //这个不是
// this.wxPayService.refound(dataMap);
// Res res = new Res();
// res.setCode(0);
// res.setMsg("退款成功!");
// return res;
// }
}
package com.ruoyi.web.controller.coffee;
import com.alibaba.fastjson.JSONObject;
import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse;
import com.github.wxpay.sdk.WXPayUtil;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.framework.web.service.WeixinServiceImpl;
import com.ruoyi.system.domain.Order;
import com.ruoyi.system.mapper.GoodsSkuMapper;
import com.ruoyi.system.mapper.OrderMapper;
import com.ruoyi.system.service.impl.AppServiceImpl;
import com.ruoyi.system.service.impl.GoodsServiceImpl;
import com.ruoyi.system.service.impl.OrderTakingServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;
@RestController
@RequestMapping("/weixin")
@Slf4j
public class WeixinController {
@Autowired
......@@ -26,7 +34,7 @@ public class WeixinController {
@Autowired
private OrderTakingServiceImpl orderTakingService;
@Autowired
private GoodsServiceImpl goodsService;
private OrderMapper orderMapper;
//这个就是那个使用传code进来的接口
@PostMapping("/login")
......@@ -43,17 +51,22 @@ public class WeixinController {
return ajax;
}
@RequestMapping("/wxNotify")
public void wxNotify(HttpServletRequest request,HttpServletResponse response){
try{
weixinService.wxNotify(request,response);
}catch (Exception e){
throw new ServiceException("微信回调发生异常");
}
/**
* 支付通知
* 微信支付通过支付通知接口将用户支付成功消息通知给商户
*/
@PostMapping("/native/notify")
public String wxNotify(HttpServletRequest request) throws Exception {
System.out.println("微信发送的回调");
return weixinService.wxNotify(request);
}
@RequestMapping("/test")
public String test(){
return goodsService.test();
public Map<String, String> test(HttpServletRequest request) throws Exception{
Order order = orderMapper.selectOrderById("8");
int amount = order.getAmount().movePointRight(2).intValue();
return null;
}
@RequestMapping("/getShop")
......@@ -68,5 +81,17 @@ public class WeixinController {
return AjaxResult.success(orderTakingService.getInfoByShop(shopId));
}
/**
* 退款回调
*
* @param xmlData
* @return
*/
@RequestMapping(method = RequestMethod.POST, value = "/refundNotify")
public String refundNotify(@RequestBody String xmlData) {
// 实现自己的逻辑
//
// 必须要返回 SUCCESS 不过有 WxPayNotifyResponse 给整合成了 xml了
return WxPayNotifyResponse.success("成功");
}
}
-----BEGIN CERTIFICATE-----
MIID6TCCAtGgAwIBAgIUY1A0gVLJqFAXYGiYwe6SS717wxMwDQYJKoZIhvcNAQEL
BQAwXjELMAkGA1UEBhMCQ04xEzARBgNVBAoTClRlbnBheS5jb20xHTAbBgNVBAsT
FFRlbnBheS5jb20gQ0EgQ2VudGVyMRswGQYDVQQDExJUZW5wYXkuY29tIFJvb3Qg
Q0EwHhcNMjIwNTA3MDY1NDAzWhcNMjcwNTA2MDY1NDAzWjB7MRMwEQYDVQQDDAox
NjI1NTExMjU3MRswGQYDVQQKDBLlvq7kv6HllYbmiLfns7vnu58xJzAlBgNVBAsM
HuWMl+S6rOWlvemlruenkeaKgOaciemZkOWFrOWPuDELMAkGA1UEBgwCQ04xETAP
BgNVBAcMCFNoZW5aaGVuMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
7pKD1B7URk6wzW06tWdtKynjuDF8GB+Q6DWUygziXONpjLyN9xkGeowC3dQvBQvH
4zhI5sYv2xUvBGhkgAUffimcsmVwZ/VP5o3ZThC0lYLkmqc4xl37cHMX8PbFUtmA
tlVg2UntiqP7K5qQev8+cULeWT0R5i48eIXv+vptzUbak/3s7mn/Bjlrl6n5l0kY
07XG8ycEbNp8dsD1dGQEfIx/RuMyHdWFSxBIXsTU4rjnVBkVbkb6mgqeNlWLHKp6
2zW9mh92vWXIRJNbaihn5KQq7JJODZUh5ba6PZFzxcySxGN5bpfcR7vNB32BvwQZ
xryP5oPRhcRoy6mwUY0g5wIDAQABo4GBMH8wCQYDVR0TBAIwADALBgNVHQ8EBAMC
BPAwZQYDVR0fBF4wXDBaoFigVoZUaHR0cDovL2V2Y2EuaXRydXMuY29tLmNuL3B1
YmxpYy9pdHJ1c2NybD9DQT0xQkQ0MjIwRTUwREJDMDRCMDZBRDM5NzU0OTg0NkMw
MUMzRThFQkQyMA0GCSqGSIb3DQEBCwUAA4IBAQCx7nNyOMU5pk8ks5L1d8tBl7Sb
b7avp5W3fR6LEtY7/JYJpH1SIyMGmFv0Qoq+sbnVzTzc3HMnE3yswKoT4J58MFuV
glvYTPuGIN7GUQ6xvGel1MG9zT6PfDJG5+yc8HeE6Z9kkYKSdbZD8vqeIgsJUO0u
LpFBx5FseR9wfe0x2xDk+mdrge+HR+VMUTHO5H8Awpi4IDNmLqU7RgNyLTSePV49
GvI1qk+g8iex+NftC8U/lj8AUEBoBGh+7e+zNHUirBJzbcVvHu8h9HBqwGPF2Zji
IU4S4joAZPpZVyqkg7yviAAOCsvRoAvEJxB1u8QGhJL0mvwrDk4eR5gpeDOc
-----END CERTIFICATE-----
-----BEGIN PRIVATE KEY-----
MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDukoPUHtRGTrDN
bTq1Z20rKeO4MXwYH5DoNZTKDOJc42mMvI33GQZ6jALd1C8FC8fjOEjmxi/bFS8E
aGSABR9+KZyyZXBn9U/mjdlOELSVguSapzjGXftwcxfw9sVS2YC2VWDZSe2Ko/sr
mpB6/z5xQt5ZPRHmLjx4he/6+m3NRtqT/ezuaf8GOWuXqfmXSRjTtcbzJwRs2nx2
wPV0ZAR8jH9G4zId1YVLEEhexNTiuOdUGRVuRvqaCp42VYscqnrbNb2aH3a9ZchE
k1tqKGfkpCrskk4NlSHltro9kXPFzJLEY3lul9xHu80HfYG/BBnGvI/mg9GFxGjL
qbBRjSDnAgMBAAECggEALiMDf4gewSICqxeOnPpNcGV/dmWLfBbOrTl/drubIx+P
j/n+8mRSjmx5OXEJTs6Cb3y5DHgTVSj5mL6fgOp8tqdReGaJoHEebJXOCnzMj4Vq
tEXWgvY14/8+CAmRC36ol5pXSm4zk/Y2Yq5XdpHZ/4lQ+q0Gwx757szoJf88MNA9
Yv5YEkW4glGlZLeP1sJD0UXZJrkC0FidQas0VhD7LuPbvmn49+gSU8PqpOg8IHSq
LaVlesP/sMdBE0zVI3Q2Qa2Ilzre5GdTEWDHtWPD0i+9oHT/B4MfCl4cNfkKrPrr
3mv2knhQyQbPVvStU5s8s4cguvlQ3m12JHO9ljBEQQKBgQD9kxzEJnWbnbd2evk4
liZYViF37rM22ZoUdjMt7663mqr3xKmQmJyVe31wBk5a3LkJKE4yn90GYIJwrDuP
JeIBlXq0Az0gFQ4WbVYEdaAyRy02Blnjg6v7XTZgqN4KzPGoYsX4FiKpLAjb8uU+
QXXnWIcHqQSOki4aUoMmxHj9MQKBgQDw2qs09/3dsPABqx0CKM3dYlupnimFZcZ+
f3lWinVdsLyDI+b9YxsUAqv21EOOAZ7cOcdZP71oB3XMxp56zo9lzY1C8EuIFB6A
lPM6eK73fAY15ShO0M48CPusHJLBcUnpQ3EMOVVr9gQiNXAP7/NEB0eBAcnWuznI
zJL2v1YZlwKBgAiBJJfXil47vel1WmJxdrvDt7+j+9K9HZPOGw1RWpTB1TYWHHHD
DI1e5Oga7gnSGUqbVXQRNIKAPh+1RxIX/Sp8bu8WpLgsvJo39IiVwVeuV2/WarFc
uynlCGvZfgjysrApD+awJ11xIqLt1I5v95pYt76kBokZkf5EAi4MrNohAoGAA7RZ
TcdCsFY4Ws429AGMqQsKPeGg4dxe4TM0upAGnhpJy/qRYvRTRkuEOZeqMlT0DI8W
8dh5IVB8D1o+tcTXj8lJku3/O2iTz4Z69ztD9aqCrfGIXS34/hNlS5Bk8XS8nknb
Q0Tee3qdNal8v8IBC9rQzrsoT5UxnlUHLaRjvqECgYB576KkTxeFv1CpDWYx0xdh
fmT8dasjt0x2g4nbjtF7gYjsxyFpcsqp5BPb5CibveV0DRe4aiwow9vsF73GY+tB
EHcbEHtL/G05TRZU2Jlcl+Kp7G2Vw79XXHTOjaFG4c7kanQNEphiN/TxqcgsoBMs
c1aZ1izfTzyR4a2AWL5xeQ==
-----END PRIVATE KEY-----
......@@ -134,12 +134,12 @@ weixin:
#商户支付密钥
key: WcCsQZXavaPXQEKuTGJlGOkzzTPxTPsr
#微信回调地址
notify-url: http://127.0.0.1/weixin/wxNotify
notify-url: http://114.115.234.81:8080/weixin/native/notify
#交易类型
trade-type: JSAPI
url: https://api.mch.weixin.qq.com/pay/unifiedorder
query-url: https://api.mch.weixin.qq.com/pay/orderquery
cert-path: zzz
cert-path: classpath:apiclient_cert.p12
#mqtt:
# url: tcp://iot-06z00dhgql5j8bw.mqtt.iothub.aliyuncs.com:1883
# clientId: h5kgirX6kNQ.XQ_000001A|securemode=2,signmethod=hmacsha256,timestamp=1651746531320|
......
wxpay.mch-id=1625511257
wxpay.mch-serial-no=da8a0b08436dd3ce560be429f14e768a
wxpay.private-key-path=apiclient_key.pem
wxpay.api-v3-key=xRu8KoCwVWbKZ8tlca3JfAZkMSV2p7tY
wxpay.appid=wx71aa3662dfd3227d
wxpay.domain=https://api.mch.weixin.qq.com
wxpay.notify-domain=https://500c-219-143-130-12.ngrok.io
wxpay.partnerKey: T6m9iK73b0kn9g5v426MKfHQH7X8rKwb
appid: wx71aa3662dfd3227d
secret: da8a0b08436dd3ce560be429f14e768a
mchid: 1625511257
#??????
key: WcCsQZXavaPXQEKuTGJlGOkzzTPxTPsr
#??????
notify-url: http://127.0.0.1/weixin/wxNotify
#????
trade-type: JSAPI
url: https://api.mch.weixin.qq.com/pay/unifiedorder
query-url: https://api.mch.weixin.qq.com/pay/orderquery
cert-path: zzz
\ No newline at end of file
......@@ -12,6 +12,14 @@ public class GenerateCode {
int andIncrement = entityIdCounter.incrementAndGet();
String number = String.format("%03d", andIncrement);
return prefix+number;
}
public static String getCode(String prefix,String fromat){
StringRedisTemplate stringRedisTemplate = SpringUtils.getBean(StringRedisTemplate.class);
RedisAtomicInteger entityIdCounter = new RedisAtomicInteger(prefix, stringRedisTemplate.getConnectionFactory());
int andIncrement = entityIdCounter.incrementAndGet();
String number = String.format(fromat, andIncrement);
return prefix+number;
}
}
......@@ -60,6 +60,7 @@
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.ruoyi.framework.web.service;
import org.apache.http.Consts;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.*;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLContextBuilder;
import org.apache.http.conn.ssl.TrustStrategy;
import org.apache.http.entity.StringEntity;
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 javax.net.ssl.SSLContext;
import java.io.IOException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.text.ParseException;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
/**
* http请求客户端
*/
public class HttpClientUtils {
private String url;
private Map<String, String> param;
private int statusCode;
private String content;
private String xmlParam;
private boolean isHttps;
public boolean isHttps() {
return isHttps;
}
public void setHttps(boolean isHttps) {
this.isHttps = isHttps;
}
public String getXmlParam() {
return xmlParam;
}
public void setXmlParam(String xmlParam) {
this.xmlParam = xmlParam;
}
public HttpClientUtils(String url, Map<String, String> param) {
this.url = url;
this.param = param;
}
public HttpClientUtils(String url) {
this.url = url;
}
public void setParameter(Map<String, String> map) {
param = map;
}
public void addParameter(String key, String value) {
if (param == null)
param = new HashMap<String, String>();
param.put(key, value);
}
public void post() throws ClientProtocolException, IOException {
HttpPost http = new HttpPost(url);
setEntity(http);
execute(http);
}
public void put() throws ClientProtocolException, IOException {
HttpPut http = new HttpPut(url);
setEntity(http);
execute(http);
}
public void get() throws ClientProtocolException, IOException {
if (param != null) {
StringBuilder url = new StringBuilder(this.url);
boolean isFirst = true;
for (String key : param.keySet()) {
if (isFirst) {
url.append("?");
isFirst = false;
}else {
url.append("&");
}
url.append(key).append("=").append(param.get(key));
}
this.url = url.toString();
}
HttpGet http = new HttpGet(url);
execute(http);
}
/**
* set http post,put param
*/
private void setEntity(HttpEntityEnclosingRequestBase http) {
if (param != null) {
List<NameValuePair> nvps = new LinkedList<NameValuePair>();
for (String key : param.keySet())
nvps.add(new BasicNameValuePair(key, param.get(key))); // 参数
http.setEntity(new UrlEncodedFormEntity(nvps, Consts.UTF_8)); // 设置参数
}
if (xmlParam != null) {
http.setEntity(new StringEntity(xmlParam, Consts.UTF_8));
}
}
private void execute(HttpUriRequest http) throws ClientProtocolException,
IOException {
CloseableHttpClient httpClient = null;
try {
if (isHttps) {
SSLContext sslContext = new SSLContextBuilder()
.loadTrustMaterial(null, new TrustStrategy() {
// 信任所有
public boolean isTrusted(X509Certificate[] chain,
String authType)
throws CertificateException {
return true;
}
}).build();
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
sslContext);
httpClient = HttpClients.custom().setSSLSocketFactory(sslsf)
.build();
} else {
httpClient = HttpClients.createDefault();
}
CloseableHttpResponse response = httpClient.execute(http);
try {
if (response != null) {
if (response.getStatusLine() != null)
statusCode = response.getStatusLine().getStatusCode();
HttpEntity entity = response.getEntity();
// 响应内容
content = EntityUtils.toString(entity, Consts.UTF_8);
}
} finally {
response.close();
}
} catch (Exception e) {
e.printStackTrace();
} finally {
httpClient.close();
}
}
public int getStatusCode() {
return statusCode;
}
public String getContent() throws ParseException, IOException {
return content;
}
}
......@@ -80,6 +80,14 @@
<version>3.2.9</version>
</dependency>
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-pay</artifactId>
<version>4.1.0</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.ruoyi.system.config;
import com.github.binarywang.wxpay.config.WxPayConfig;
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
@Component
public class WeChatPayConfig {
@Value("${weixin.appid}")
private String appid;
@Value("${weixin.secret}")
private String secret;
@Value("${weixin.mchid}")
private String mchId;
@Value("${weixin.key}")
private String key;
@Value("${weixin.notify-url}")
private String notifyUrl;
@Value("${weixin.trade-type}")
private String tradeType;
@Value("${weixin.url}")
private String url;
@Value("${weixin.query-url}")
private String queryUrl;
@Value("${weixin.cert-path}")
private String certPath;
@Bean
@ConditionalOnMissingBean
public WxPayConfig payConfig() {
WxPayConfig payConfig = new WxPayConfig();
payConfig.setAppId(appid);
payConfig.setMchId(mchId);
payConfig.setMchKey(key);
payConfig.setKeyPath(certPath);
payConfig.setTradeType("JSAPI");
payConfig.setNotifyUrl(notifyUrl);
return payConfig;
}
@Bean
public WxPayService wxPayService(WxPayConfig payConfig) {
WxPayService wxPayService = new WxPayServiceImpl();
wxPayService.setConfig(payConfig);
return wxPayService;
}
}
\ No newline at end of file
......@@ -47,6 +47,16 @@ public class GoodsSku extends BaseEntity
@Excel(name = "价格")
private BigDecimal price;
public BigDecimal getDiscount() {
return discount;
}
public void setDiscount(BigDecimal discount) {
this.discount = discount;
}
private BigDecimal discount;
public void setId(long id)
{
this.id = id;
......
package com.ruoyi.system.domain;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
......@@ -16,7 +17,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
* @author ruoyi
* @date 2022-04-28
*/
public class Order extends BaseEntity
public class Order implements Serializable
{
private static final long serialVersionUID = 1L;
......@@ -91,6 +92,16 @@ public class Order extends BaseEntity
@Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date updatedAt;
private Shop shop;
public Shop getShop() {
return shop;
}
public void setShop(Shop shop) {
this.shop = shop;
}
private List<OrderDetail> orderDetails ;
public List<OrderDetail> getOrderDetails() {
......
package com.ruoyi.system.domain;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
......@@ -14,7 +15,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
* @author ruoyi
* @date 2022-04-28
*/
public class OrderDetail extends BaseEntity
public class OrderDetail implements Serializable
{
private static final long serialVersionUID = 1L;
......
......@@ -47,6 +47,36 @@ public class OrderRefund extends BaseEntity
@Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date updatedAt;
private String refundNo;
public String getRefundNo() {
return refundNo;
}
public void setRefundNo(String refundNo) {
this.refundNo = refundNo;
}
public String getOrderNo() {
return orderNo;
}
public void setOrderNo(String orderNo) {
this.orderNo = orderNo;
}
private String orderNo;
public Order getOrder() {
return order;
}
public void setOrder(Order order) {
this.order = order;
}
private Order order;
public void setId(String id)
{
this.id = id;
......
......@@ -2,12 +2,19 @@ package com.ruoyi.system.domain.vo;
public class ResultVo {
public class ResultVo<T> {
private String code;
private String message;
public static ResultVo error(String message) {
ResultVo resultVo = new ResultVo();
resultVo.setCode("99");
resultVo.setMessage(message);
return resultVo;
}
public String getCode() {
return code;
}
......@@ -24,13 +31,27 @@ public class ResultVo {
this.message = message;
}
public String getData() {
public T getData() {
return data;
}
public void setData(String data) {
public void setData(T data) {
this.data = data;
}
private String data;
private T data;
public static ResultVo success(){
ResultVo resultVo = new ResultVo();
resultVo.setCode("0");
return resultVo;
}
public static <T> ResultVo success(T t){
ResultVo resultVo = new ResultVo();
resultVo.setCode("0");
resultVo.setData(t);
return resultVo;
}
}
package com.ruoyi.system.domain.vo.orderTaking;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import java.util.List;
......@@ -78,27 +79,51 @@ public class GoodsVo {
this.tags = tags;
}
public JSONObject getPics() {
return pics;
private String discount;
private String pictures;
private JSONObject pics;
public String getPictures() {
return pictures;
}
public void setPics(JSONObject pics) {
this.pics = pics;
public void setPictures(String pictures) {
this.pictures = pictures;
}
public String getSpecs() {
public JSONArray getSpecs() {
return specs;
}
public void setSpecs(String specs) {
public void setSpecs(JSONArray specs) {
this.specs = specs;
}
private String discount;
private JSONObject pics;
private String desc;
public JSONObject getPics() {
return pics;
}
public String getSpecString() {
return specString;
}
public void setSpecString(String specString) {
this.specString = specString;
}
public void setPics(JSONObject pics) {
this.pics = pics;
}
private String desc;
private String remarks;
private List<String> tags;
private String specs;
private JSONArray specs;
private String specString;
}
package com.ruoyi.system.domain.vo.orderTaking;
import com.alibaba.fastjson.JSONObject;
public class ImagesVo {
private String left;
......@@ -12,13 +14,13 @@ public class ImagesVo {
this.left = left;
}
public String getRight() {
public JSONObject getRight() {
return right;
}
public void setRight(String right) {
public void setRight(JSONObject right) {
this.right = right;
}
private String right;
private JSONObject right;
}
......@@ -49,11 +49,21 @@ public class OrderTakingVo implements Serializable {
private String tips;
public String getShopState() {
return shopState;
}
public void setShopState(String shopState) {
this.shopState = shopState;
}
private String countOfOrder;
private List<CategoryVo> categorys;
private List<RecommendVo> recommends;
private String shopState;
}
......@@ -32,14 +32,14 @@ public class RecommendVo implements Serializable {
this.desc = desc;
}
public List<GoodsVo> getGoods() {
public GoodsVo getGoods() {
return goods;
}
public void setGoods(List<GoodsVo> goods) {
public void setGoods(GoodsVo goods) {
this.goods = goods;
}
private String desc;
private List<GoodsVo> goods;
private GoodsVo goods;
}
package com.ruoyi.system.domain.vo.orderTaking;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import java.io.Serializable;
import java.util.List;
......@@ -32,9 +35,7 @@ public class SkuVo implements Serializable {
this.price = price;
}
public String getRules() {
return rules;
}
public String getIsDefault() {
return isDefault;
......@@ -44,15 +45,41 @@ public class SkuVo implements Serializable {
this.isDefault = isDefault;
}
public void setRules(String rules) {
public JSONArray getRules() {
return rules;
}
public void setRules(JSONArray rules) {
this.rules = rules;
}
private String price;
private String rules;
private JSONArray rules;
public String getRulesString() {
return rulesString;
}
public void setRulesString(String rulesString) {
this.rulesString = rulesString;
}
public String getDisCount() {
return discount;
}
public void setDisCount(String discount) {
this.discount = discount;
}
/**
* 0 默认
*/
private String isDefault;
private String rulesString;
private String discount;
}
......@@ -58,4 +58,6 @@ public interface GoodsMapper
* @return 结果
*/
public int deleteGoodsByIds(String[] ids);
Integer selectCount(String id);
}
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.OrderRefund;
/**
......@@ -33,7 +35,7 @@ public interface IOrderRefundService
* @param orderRefund 订单退款
* @return 结果
*/
public int insertOrderRefund(OrderRefund orderRefund);
public AjaxResult insertOrderRefund(OrderRefund orderRefund);
/**
* 修改订单退款
......
......@@ -49,10 +49,7 @@ public class GoodsCategoryServiceImpl implements IGoodsCategoryService
{
List<GoodsCategory> goodsCategories = goodsCategoryMapper.selectGoodsCategoryList(goodsCategory);
for (GoodsCategory category : goodsCategories) {
Goods goods = new Goods();
goods.setCategory(category.getId());
goods.setIsDeleted(0L);
category.setGoodsCount(goodsMapper.selectGoodsList(goods).size());
category.setGoodsCount(goodsMapper.selectCount(category.getId()));
}
return goodsCategories;
}
......
......@@ -6,7 +6,6 @@ import java.util.Date;
import java.util.List;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.GenerateCode;
import com.ruoyi.common.utils.StringUtils;
......@@ -123,7 +122,7 @@ public class GoodsServiceImpl implements IGoodsService
}
}
}
createSku(ruleNodeList,goodsId,goods.getDiscount());
createSku(ruleNodeList,goodsId,goods.getDiscount(),goods.getPrice());
}
List<GoodsTag> goodsTagList = goods.getGoodsTagList();
if(goodsTagList!=null &&!goodsTagList.isEmpty()){
......@@ -136,15 +135,16 @@ public class GoodsServiceImpl implements IGoodsService
}
}
private void createSku(List<RuleNode> ruleNodeList, long goodsId, BigDecimal price) {
private void createSku(List<RuleNode> ruleNodeList, long goodsId, BigDecimal discount,BigDecimal price) {
for (RuleNode<SpecRule> ruleNode : ruleNodeList) {
List<SpecRule> specRuleList = new ArrayList<>();
BigDecimal bigDecimal = new BigDecimal(price.toString());
BigDecimal disCount = new BigDecimal(discount.toString());
RuleNode<SpecRule> parentRuleNode = ruleNode.getParentRuleNode();
specRuleList.add(ruleNode.getRuleNode());
bigDecimal = bigDecimal.add(ruleNode.getRuleNode().getAmount());
if(parentRuleNode!=null){
findPartentRuleNode(parentRuleNode,specRuleList,bigDecimal);
findPartentRuleNode(parentRuleNode,specRuleList,bigDecimal,disCount);
}
GoodsSku goodsSku = new GoodsSku();
goodsSku.setGoodsId(goodsId);
......@@ -152,17 +152,19 @@ public class GoodsServiceImpl implements IGoodsService
goodsSku.setIsDeleted("0");
goodsSku.setUpdatedAt(new Date());
goodsSku.setPrice(bigDecimal);
goodsSku.setDiscount(discount);
goodsSku.setRuleList(JSONArray.toJSONString(specRuleList));
goodsSkuMapper.insertGoodsSku(goodsSku);
}
}
private void findPartentRuleNode(RuleNode<SpecRule> ruleRuleNode, List<SpecRule> specRuleList, BigDecimal bigDecimal) {
private void findPartentRuleNode(RuleNode<SpecRule> ruleRuleNode, List<SpecRule> specRuleList, BigDecimal bigDecimal, BigDecimal disCount) {
specRuleList.add(ruleRuleNode.getRuleNode());
bigDecimal = bigDecimal.add(ruleRuleNode.getRuleNode().getAmount());
disCount = disCount.add(ruleRuleNode.getRuleNode().getAmount());
RuleNode<SpecRule> parentRuleNode = ruleRuleNode.getParentRuleNode();
if(parentRuleNode!=null){
findPartentRuleNode(parentRuleNode,specRuleList, bigDecimal);
findPartentRuleNode(parentRuleNode,specRuleList, bigDecimal, disCount);
}
}
......
package com.ruoyi.system.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.system.domain.Order;
import com.ruoyi.system.domain.ShopGoods;
import com.ruoyi.system.domain.ShopGoodsSku;
import com.ruoyi.system.mapper.OrderMapper;
import com.ruoyi.system.mapper.ShopGoodsMapper;
import com.ruoyi.system.mapper.ShopGoodsSkuMapper;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.domain.vo.ResultVo;
import com.ruoyi.system.mapper.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.util.Date;
import java.util.List;
@Service
@Slf4j
public class MachineApiServiceImpl {
@Autowired
private ShopGoodsMapper shopGoodsMapper;
......@@ -20,31 +25,102 @@ public class MachineApiServiceImpl {
private OrderMapper orderMapper;
@Autowired
private ShopGoodsSkuMapper shopGoodsSkuMapper;
@Autowired
private OrderDetailMapper orderDetailMapper;
@Value("machine.url")
private String url;
@Autowired
private RestTemplate restTemplate;
@Autowired
private MachineMapper machineMapper;
public String shopGoodsUpdate(JSONObject jsonObject) {
String shopID = jsonObject.getString("shopID");
String skuIDs = jsonObject.getString("skuID");
String shopID = jsonObject.getString("shopId");
String skuIDs = jsonObject.getString("skuId");
List<String> skuIds = JSONObject.parseArray(skuIDs, String.class);
String robotID = jsonObject.getString("robotID");
String robotID = jsonObject.getString("robotId");
String status = jsonObject.getString("status");
if("11".equals(status)){
status ="2";
}else{
status ="1";
}
shopGoodsSkuMapper.updateSkuStatus(skuIds, robotID, shopID, status);
return "0";
int i = shopGoodsSkuMapper.updateSkuStatus(skuIds, robotID, shopID, status);
return ""+i;
}
public String updateOrder(JSONObject jsonObject) {
String orderID = jsonObject.getString("orderID");
String orderID = jsonObject.getString("orderId");
String status = jsonObject.getString("status");
Order order = new Order();
order.setId(orderID);
order.setState(status);
orderMapper.updateOrder(order);
return "0";
int i = orderMapper.updateOrder(order);
return i+"";
}
public void testOrder(String orderId) {
if(StringUtils.isEmpty(orderId)){
orderId = "8";
}
Order order = orderMapper.selectOrderById(orderId);
OrderDetail orderDetail =new OrderDetail();
orderDetail.setOrderId(order.getId());
List<OrderDetail> orderDetails = orderDetailMapper.selectOrderDetailList(orderDetail);
order.setOrderDetails(orderDetails);
String orderInfo = JSONObject.toJSONString(order);
ResultVo resultVo =createOrder(orderInfo,"/v1/order");
String code = resultVo.getCode();
if("2001".equals(code)){
throw new ServiceException("库存不足");
}else if("3001".equals(code)){
throw new ServiceException("机器繁忙");
}
}
public ResultVo createOrder(String param,String interfaceName){
try{
String postUrl = url+interfaceName;
log.info("请求创建订单接口:【{}】",param);
ResponseEntity<String> stringResponseEntity = restTemplate.postForEntity(postUrl, param, String.class);
log.info("请求创建订单接口返回结果为:【{}】",stringResponseEntity.getBody());
ResultVo resultVo = JSONObject.parseObject(stringResponseEntity.getBody(), ResultVo.class);
return resultVo;
}catch (Exception e){
log.error("请求发生异常:",e);
throw new ServiceException("服务器繁忙,请重试");
}
}
public void testOrderUpdate(String orderId) {
if(StringUtils.isEmpty(orderId)){
orderId = "8";
}
JSONObject param = new JSONObject();
JSONObject data = new JSONObject();
data.put("state",2);
data.put("payTime",new Date());
param.put("data",data);
param.put("orderId",orderId);
createOrder(param.toJSONString(),"/v1/order/update");
}
public Object robotUpdate(JSONObject jsonObject) {
String robotID = jsonObject.getString("robotID");
String status = jsonObject.getString("status");
Long shopID = jsonObject.getLong("shopID");
Machine machine = new Machine();
machine.setShopId(shopID);
machine.setId(robotID);
List<Machine> machines = machineMapper.selectMachineList(machine);
if(machines.isEmpty()){
throw new ServiceException("该机器未绑定店铺") ;
}
machine.setState(status);
return machineMapper.updateMachine(machine);
}
}
......@@ -2,6 +2,11 @@ package com.ruoyi.system.service.impl;
import java.util.Date;
import java.util.List;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.GenerateCode;
import com.ruoyi.system.domain.Order;
import com.ruoyi.system.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.OrderRefundMapper;
......@@ -19,6 +24,10 @@ public class OrderRefundServiceImpl implements IOrderRefundService
{
@Autowired
private OrderRefundMapper orderRefundMapper;
@Autowired
private OrderServiceImpl orderService;
@Autowired
private OrderMapper orderMapper;
/**
* 查询订单退款
......@@ -41,7 +50,13 @@ public class OrderRefundServiceImpl implements IOrderRefundService
@Override
public List<OrderRefund> selectOrderRefundList(OrderRefund orderRefund)
{
return orderRefundMapper.selectOrderRefundList(orderRefund);
List<OrderRefund> orderRefunds = orderRefundMapper.selectOrderRefundList(orderRefund);
for (OrderRefund refund : orderRefunds) {
Order order = orderService.selectOrderById(refund.getOrderId());
refund.setOrder(order);
}
return orderRefunds;
}
/**
......@@ -51,12 +66,31 @@ public class OrderRefundServiceImpl implements IOrderRefundService
* @return 结果
*/
@Override
public int insertOrderRefund(OrderRefund orderRefund)
public AjaxResult insertOrderRefund(OrderRefund orderRefund)
{
Order order = orderMapper.selectOrderById(orderRefund.getOrderId());
if(order ==null ){
return AjaxResult.error("找不到该订单");
}
// 制作中、制作完成、聚餐中、已完成
String state = order.getState();
if("2".equals(state)||"3".equals(state)){
// 4 支付制作中 5 制作完成未取 6 取餐中 7 取餐完成
}else if("4".equals(state)||"5".equals(state)||"6".equals(state)||"7".equals(state)){
}else{
return AjaxResult.error("该订单状态不允许退款");
}
orderRefund.setCreatedAt(new Date());
orderRefund.setUpdatedAt(new Date());
orderRefund.setState("0");
return orderRefundMapper.insertOrderRefund(orderRefund);
orderRefund.setOrderNo(order.getOrderNo());
orderRefund.setRefundNo(GenerateCode.getCode("R","%09d"));
int i = orderRefundMapper.insertOrderRefund(orderRefund);
return AjaxResult.success(orderRefund);
}
/**
......
......@@ -45,6 +45,8 @@ public class OrderServiceImpl implements IOrderService
private MachineMapper machineMapper;
@Autowired
private RobotServiceImpl robotService;
@Autowired
private ShopMapper shopMapper;
......@@ -108,7 +110,7 @@ public class OrderServiceImpl implements IOrderService
List<Machine> machines = machineMapper.selectMachineList(machine);
if(machines!=null &&!machines.isEmpty()){
Machine machine1 = machines.get(0);
if(!"1".equals(machine1)){
if(!"1".equals(machine1.getState())){
return AjaxResult.error("机器暂时不可用");
}
machineId = machine1.getCode();
......@@ -128,7 +130,7 @@ public class OrderServiceImpl implements IOrderService
}
}
//发送数据给机器
robotService.createOrder(order);
//robotService.createOrder(order);
return AjaxResult.success(order.getOrderNo());
}
......@@ -187,7 +189,7 @@ public class OrderServiceImpl implements IOrderService
return AjaxResult.error("该商品已不存在:"+orderDetail.getGoodsName());
}
ShopGoodsSku shopGoodsSku1 = shopGoodsSkus.get(0);
if(!"1".equals(shopGoodsSku1)){
if(!"1".equals(shopGoodsSku1.getState())){
return AjaxResult.error("该商品所选种类已经告罄,请重新进行选择:"+orderDetail.getGoodsName());
}
}
......@@ -198,6 +200,7 @@ public class OrderServiceImpl implements IOrderService
public List<Order> getMyOrder(String openId) {
List<Order> orders = orderMapper.selectByUserId(openId);
for (Order order : orders) {
order.setShop(shopMapper.selectShopById(order.getShopId()));
OrderDetail orderDetail = new OrderDetail();
orderDetail.setOrderId(order.getId());
List<OrderDetail> orderDetails = orderDetailMapper.selectOrderDetailList(orderDetail);
......@@ -220,10 +223,12 @@ public class OrderServiceImpl implements IOrderService
String format = simpleDateFormat.format(new Date());
String redisKey = "shopId"+format+shopId;
RedisAtomicInteger redisAtomicInteger = new RedisAtomicInteger(redisKey,SpringUtils.getBean(StringRedisTemplate.class).getConnectionFactory());
redisAtomicInteger.set(30);
if(0 == redisAtomicInteger.getAndIncrement()){
redisAtomicInteger.set(30);
}
redisAtomicInteger.expire(1, TimeUnit.DAYS);
int andIncrement = redisAtomicInteger.getAndIncrement();
return key+andIncrement;
return key+String.format("%03d",andIncrement);
}
//获取订单号
private String getOrderNo(String source){
......@@ -231,11 +236,11 @@ public class OrderServiceImpl implements IOrderService
if(StringUtils.isNotEmpty(source)){
if("1".equals(source)){
channel="A";
}else{
}else if("2".equals(source)){
channel="B";
}
}
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd HH");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHH");
String format = simpleDateFormat.format(new Date());
String key = "orderNo";
RedisAtomicInteger redisAtomicInteger = new RedisAtomicInteger(key,SpringUtils.getBean(StringRedisTemplate.class).getConnectionFactory());
......
......@@ -30,6 +30,8 @@ public class OrderTakingServiceImpl {
private ShopGoodsMapper shopGoodsMapper;
@Autowired
private GoodsCategoryMapper goodsCategoryMapper;
@Autowired
private ShopMapper shopMapper;
/**
......@@ -57,11 +59,16 @@ public class OrderTakingServiceImpl {
}
public OrderTakingVo getOrderTakingInfo(Long shopId){
OrderTakingVo orderTakingVo = new OrderTakingVo();
Shop shop = shopMapper.selectShopById(String.valueOf(shopId));
orderTakingVo.setShopState(shop.getState());
ImagesVo imagesVo = new ImagesVo();
orderTakingVo.setImages(imagesVo);
imagesVo.setLeft(sysConfigService.selectConfigByKey("menu.left"));
imagesVo.setRight(sysConfigService.selectConfigByKey("menu.right"));
imagesVo.setRight(JSONObject.parseObject(sysConfigService.selectConfigByKey("menu.right")));
orderTakingVo.setCountOfOrder(sysConfigService.selectConfigByKey("goods.limit"));
orderTakingVo.setTips(sysConfigService.selectConfigByKey("tips.address"));
List<CategoryVo> categoryVos = new ArrayList<>();
......@@ -75,8 +82,12 @@ public class OrderTakingServiceImpl {
for (GoodsVo goodsVo : goodsVos) {
GoodsTag goodsTag = new GoodsTag();
goodsTag.setState("1");
goodsVo.setSpecs(buildGoodsSpec(goodsVo.getSpecs()));
goodsVo.setSpecs(buildGoodsSpec(goodsVo.getSpecString()));
goodsVo.setSpecString(null);
goodsTag.setGoodsId(Long.parseLong(goodsVo.getGoodsId()));
goodsVo.setPics(JSONObject.parseObject(goodsVo.getPictures()));
goodsVo.setPictures(null);
List<GoodsTag> goodsTags = goodsTagMapper.selectGoodsTagList(goodsTag);
List<String> tags = goodsTags.stream().map(GoodsTag::getTag).collect(Collectors.toList());
goodsVo.setTags(tags);
......@@ -104,8 +115,9 @@ public class OrderTakingServiceImpl {
goodsVo.setPrice(good.getPrice().stripTrailingZeros().toPlainString());
goodsVo.setPics(JSONObject.parseObject(good.getPics()));
goodsVo.setRemarks(good.getRemarks());
goodsVo.setSpecs(good.getSpec());
goodsVo.setSpecs(buildGoodsSpec(goodsVo.getSpecs()));
goodsVo.setSpecs(buildGoodsSpec(good.getSpec()));
goodsVo.setSpecString(null);
GoodsTag goodsTag = new GoodsTag();
goodsTag.setState("1");
goodsTag.setGoodsId(Long.parseLong(goodsVo.getGoodsId()));
......@@ -133,8 +145,11 @@ public class OrderTakingServiceImpl {
recommendVo.setDesc(shopRecommend1.getDesc());
recommendVo.setGoodsName(shopRecommend1.getGoodsName());
recommendVo.setPic(shopRecommend1.getPic());
recommendVo.setGoods(recommendGoods);
goodsVo.setSpecs(buildGoodsSpec(goodsVo.getSpecs()));
recommendVo.setGoods(goodsVo);
goodsVo.setSpecs(buildGoodsSpec(goodsVo.getSpecString()));
goodsVo.setSpecString(null);
goodsVo.setPics(JSONObject.parseObject(goodsVo.getPictures()));
goodsVo.setPictures(null);
GoodsTag goodsTag = new GoodsTag();
goodsTag.setState("1");
goodsTag.setGoodsId(Long.parseLong(goodsVo.getGoodsId()));
......@@ -154,7 +169,7 @@ public class OrderTakingServiceImpl {
private void buildSkuRules(List<SkuVo> skuVos) {
for (SkuVo skuVo : skuVos) {
String rules = skuVo.getRules();
String rules = skuVo.getRulesString();
List<SpecRule> specRuleList = JSONObject.parseArray(rules, SpecRule.class);
boolean boo =true;
List<SkuRuleVo> skuRuleVos = new ArrayList<>();
......@@ -172,13 +187,14 @@ public class OrderTakingServiceImpl {
if(boo){
skuVo.setIsDefault("1");
}
skuVo.setRules(JSONObject.toJSONString(skuRuleVos));
skuVo.setRules(JSONObject.parseArray(JSONObject.toJSONString(skuRuleVos)));
skuVo.setRulesString(null);
}
}
private String buildGoodsSpec(String specs) {
private JSONArray buildGoodsSpec(String specs) {
List<Spec> specList = JSONObject.parseArray(specs,Spec.class);
List<SpecVo> specVos = new ArrayList<>();
for (Spec spec : specList) {
......@@ -199,7 +215,7 @@ public class OrderTakingServiceImpl {
}
}
return JSONObject.toJSONString(specVos);
return JSONArray.parseArray(JSONObject.toJSONString(specVos));
}
......
package com.ruoyi.system.utils;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.system.domain.OrderLog;
import com.ruoyi.system.mapper.OrderLogMapper;
import org.springframework.beans.factory.annotation.Autowired;
public class OrderLogUtils {
private OrderLogMapper orderLogMapper = SpringUtils.getBean(OrderLogMapper.class);
public void insertLog(String orderId){
OrderLog orderLog = new OrderLog();
}
}
......@@ -118,4 +118,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</delete>
<select id="selectCount" resultType="integer">
select count(*) from goods where category=#{id}
</select>
</mapper>
\ No newline at end of file
......@@ -12,10 +12,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="createdAt" column="created_at" />
<result property="updatedAt" column="updated_at" />
<result property="price" column="price" />
<result property="discount" column="discount"/>
</resultMap>
<sql id="selectGoodsSkuVo">
select id, goods_id, rule_list, is_deleted, created_at, updated_at, price from goods_sku
select id, goods_id, rule_list, is_deleted, created_at, updated_at, price,discount from goods_sku
</sql>
<select id="selectGoodsSkuList" parameterType="GoodsSku" resultMap="GoodsSkuResult">
......@@ -28,6 +29,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createdAt != null "> and created_at = #{createdAt}</if>
<if test="updatedAt != null "> and updated_at = #{updatedAt}</if>
<if test="price != null "> and price = #{price}</if>
<if test="discount != null "> and discount = #{discount}</if>
</where>
</select>
......@@ -45,6 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createdAt != null">created_at,</if>
<if test="updatedAt != null">updated_at,</if>
<if test="price != null">price,</if>
<if test="discount != null">discount,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="goodsId != null and goodsId != ''">#{goodsId},</if>
......@@ -53,6 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createdAt != null">#{createdAt},</if>
<if test="updatedAt != null">#{updatedAt},</if>
<if test="price != null">#{price},</if>
<if test="discount != null">#{discount},</if>
</trim>
</insert>
......@@ -65,6 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createdAt != null">created_at = #{createdAt},</if>
<if test="updatedAt != null">updated_at = #{updatedAt},</if>
<if test="price != null">price = #{price},</if>
<if test="discount != null">price = #{discount},</if>
</trim>
where id = #{id}
</update>
......
......@@ -22,11 +22,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="state" column="state" />
<result property="createdAt" column="created_at" />
<result property="updatedAt" column="updated_at" />
<result property="shelfAt" column="shelf_at"></result>
</resultMap>
<sql id="selectOrderVo">
select id, order_no, order_num, user_id, user_name, user_phone, pay_time, finish_time, amount, goods_num, pick_code, shop_id, machine_id, source, state, created_at, updated_at,shelf_at from `order`
select id, order_no, order_num, user_id, user_name, user_phone, pay_time, finish_time, amount, goods_num, pick_code, shop_id, machine_id, source, state, created_at, updated_at from `order`
</sql>
<select id="selectOrderList" parameterType="Order" resultMap="OrderResult">
......@@ -48,7 +47,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="state != null and state != ''"> and state = #{state}</if>
<if test="createdAt != null "> and created_at = #{createdAt}</if>
<if test="updatedAt != null "> and updated_at = #{updatedAt}</if>
<if test="shelf_at != null "> and shelf_at = #{shelfAt}</if>
</where>
</select>
......@@ -59,7 +57,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<insert id="insertOrder" parameterType="Order" useGeneratedKeys="true" keyProperty="id">
insert into order
insert into `order`
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="orderNo != null and orderNo != ''">order_no,</if>
<if test="orderNum != null and orderNum != ''">order_num,</if>
......@@ -77,7 +75,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="state != null and state != ''">state,</if>
<if test="createdAt != null">created_at,</if>
<if test="updatedAt != null">updated_at,</if>
<if test="shelfAt != null">shelf_at,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderNo != null and orderNo != ''">#{orderNo},</if>
......@@ -96,12 +93,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="state != null and state != ''">#{state},</if>
<if test="createdAt != null">#{createdAt},</if>
<if test="updatedAt != null">#{updatedAt},</if>
<if test="shelfAt != null">#{shelfAt},</if>
</trim>
</insert>
<update id="updateOrder" parameterType="Order">
update order
update `order`
<trim prefix="SET" suffixOverrides=",">
<if test="orderNo != null and orderNo != ''">order_no = #{orderNo},</if>
<if test="orderNum != null and orderNum != ''">order_num = #{orderNum},</if>
......@@ -119,7 +115,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="state != null and state != ''">state = #{state},</if>
<if test="createdAt != null">created_at = #{createdAt},</if>
<if test="updatedAt != null">updated_at = #{updatedAt},</if>
<if test="shelfAt != null">shelf_at = #{shelfAt},</if>
</trim>
where id = #{id}
</update>
......
......@@ -92,7 +92,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
g.remarks,
sg.state,
g.code
from shop_goods sg ,goods g where sg.goods_id =g.id and g.state ='1' and g.is_deleted =0
from shop_goods sg ,goods g where sg.goods_id =g.id and g.state ='3' and g.is_deleted =0
and shop_id =#{shopId} and category =#{categoryId}
order by sg.turn
</select>
......
......@@ -100,7 +100,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
gs.id as skuId,
sgs.state as state ,
gs.price as price,
gs.rule_list as rules
gs.discount as discount,
gs.rule_list as rulesString
from
goods_sku gs ,
shop_goods_sku sgs
......
......@@ -114,8 +114,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
g.name as name,
g.price as price,
g.discount as discount,
g.pics ,
g.spec as specs,
g.pics as pictures ,
g.spec as specString,
g.`desc`,
g.remarks
from
......@@ -144,16 +144,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
sg.state,
g.code
from
shop_goods sg ,
goods g,
shop_recommend sr
shop_recommend sr,
shop_goods sg,
goods g
where
sg.goods_id = g.id
and g.state = '1'
sr.goods_id = sg.goods_id
and g.id = sg.goods_id
and g.state = '3'
and g.is_deleted = 0
and sr.shop_id =sg.shop_id
and sr.`type` =#{type}
and sr.shop_id =#{shopId}
and sr.`type` = #{type}
and sr.shop_id = #{shopId}
order by
sr.turn
</select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment