修改库存
This commit is contained in:
@@ -124,4 +124,13 @@ public class OrderController {
|
|||||||
@RequestParam("id") Integer id){
|
@RequestParam("id") Integer id){
|
||||||
return orderService.orderDetail(shopId,id);
|
return orderService.orderDetail(shopId,id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "sendMessage")
|
||||||
|
public Result sendMessage(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName,
|
||||||
|
@RequestHeader("clientType") String clientType,@RequestParam("orderId") String orderId){
|
||||||
|
|
||||||
|
return orderService.sendMassage(orderId);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,13 @@ package com.chaozhanggui.system.cashierservice.dao;
|
|||||||
|
|
||||||
import com.chaozhanggui.system.cashierservice.entity.TbProductSku;
|
import com.chaozhanggui.system.cashierservice.entity.TbProductSku;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.TbProductSkuWithBLOBs;
|
import com.chaozhanggui.system.cashierservice.entity.TbProductSkuWithBLOBs;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.po.ProductSkuPo;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface TbProductSkuMapper {
|
public interface TbProductSkuMapper {
|
||||||
@@ -33,4 +36,7 @@ public interface TbProductSkuMapper {
|
|||||||
void updateByskuIdSub(@Param("skuId")Integer skuId, @Param("num")Integer num);
|
void updateByskuIdSub(@Param("skuId")Integer skuId, @Param("num")Integer num);
|
||||||
|
|
||||||
void updateStockNum(@Param("skuId") Integer skuId, @Param("num") Integer num);
|
void updateStockNum(@Param("skuId") Integer skuId, @Param("num") Integer num);
|
||||||
|
|
||||||
|
|
||||||
|
void batchStockNum(@Param("list")List<ProductSkuPo> list);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.entity.po;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ProductSkuPo implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
|
private Integer skuId;
|
||||||
|
|
||||||
|
private Integer number;
|
||||||
|
|
||||||
|
public ProductSkuPo(Integer skuId, Integer number) {
|
||||||
|
this.skuId = skuId;
|
||||||
|
this.number = number;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,6 +19,7 @@ public class WebAppConfigurer implements WebMvcConfigurer {
|
|||||||
.addPathPatterns("/**")
|
.addPathPatterns("/**")
|
||||||
.excludePathPatterns("/login/login")
|
.excludePathPatterns("/login/login")
|
||||||
.excludePathPatterns("/cloudPrinter/print")
|
.excludePathPatterns("/cloudPrinter/print")
|
||||||
.excludePathPatterns("/cloudPrinter/handoverPrint");
|
.excludePathPatterns("/cloudPrinter/handoverPrint")
|
||||||
|
.excludePathPatterns("/order/sendMessage");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -238,10 +238,13 @@ public class CloudPrinterService {
|
|||||||
String balance = "0";
|
String balance = "0";
|
||||||
|
|
||||||
if ("deposit".equals(orderInfo.getPayType())) {
|
if ("deposit".equals(orderInfo.getPayType())) {
|
||||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMemberId()));
|
if(ObjectUtil.isNotEmpty(orderInfo.getMemberId())&&ObjectUtil.isNotNull(orderInfo.getMemberId())){
|
||||||
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
|
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMemberId()));
|
||||||
balance = user.getAmount().toPlainString();
|
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
|
||||||
|
balance = user.getAmount().toPlainString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if(ObjectUtil.isNotEmpty(detailList)&&detailList.size()>0){
|
if(ObjectUtil.isNotEmpty(detailList)&&detailList.size()>0){
|
||||||
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp")?orderInfo.getTableName():orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance,(ObjectUtil.isEmpty(orderInfo.getPayType())||ObjectUtil.isNull(orderInfo.getPayType())?"":orderInfo.getPayType() ), "0", detailList,orderInfo.getRemark());
|
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp")?orderInfo.getTableName():orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance,(ObjectUtil.isEmpty(orderInfo.getPayType())||ObjectUtil.isNull(orderInfo.getPayType())?"":orderInfo.getPayType() ), "0", detailList,orderInfo.getRemark());
|
||||||
@@ -370,7 +373,7 @@ public class CloudPrinterService {
|
|||||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||||
cashierCarts.parallelStream().forEach(it->{
|
cashierCarts.parallelStream().forEach(it->{
|
||||||
Long count= categoryInfos.stream().filter(c->
|
Long count= categoryInfos.stream().filter(c->
|
||||||
c.getId().equals(it.getCategoryId())
|
c.getId().toString().equals(it.getCategoryId().toString())
|
||||||
).count();
|
).count();
|
||||||
|
|
||||||
if(count>0) {
|
if(count>0) {
|
||||||
@@ -625,7 +628,7 @@ public class CloudPrinterService {
|
|||||||
// memberData.add(new HandoverInfo.MemberData(ObjectUtil.isNull(shopUserDuty.getMemberOutAmount())? BigDecimal.ONE.toPlainString() : shopUserDuty.getMemberOutAmount().toPlainString(),"储值卡支付"));
|
// memberData.add(new HandoverInfo.MemberData(ObjectUtil.isNull(shopUserDuty.getMemberOutAmount())? BigDecimal.ONE.toPlainString() : shopUserDuty.getMemberOutAmount().toPlainString(),"储值卡支付"));
|
||||||
}
|
}
|
||||||
|
|
||||||
memberData.add(new HandoverInfo.MemberData(ObjectUtil.isNull(shopUserDuty.getMemberInAmount())? BigDecimal.ONE.toPlainString() : shopUserDuty.getMemberInAmount().toPlainString(),"会员卡充值"));
|
memberData.add(new HandoverInfo.MemberData(ObjectUtil.isNull(shopUserDuty.getMemberInAmount())? BigDecimal.ZERO.toPlainString() : shopUserDuty.getMemberInAmount().toPlainString(),"会员卡充值"));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,20 @@
|
|||||||
package com.chaozhanggui.system.cashierservice.service;
|
package com.chaozhanggui.system.cashierservice.service;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.http.HttpRequest;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.chaozhanggui.system.cashierservice.dao.*;
|
import com.chaozhanggui.system.cashierservice.dao.*;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.*;
|
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.po.CartPo;
|
import com.chaozhanggui.system.cashierservice.entity.po.CartPo;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.po.OrderPo;
|
import com.chaozhanggui.system.cashierservice.entity.po.OrderPo;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.po.ProductSkuPo;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.po.QueryCartPo;
|
import com.chaozhanggui.system.cashierservice.entity.po.QueryCartPo;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.vo.CartVo;
|
import com.chaozhanggui.system.cashierservice.entity.vo.CartVo;
|
||||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||||
import com.chaozhanggui.system.cashierservice.util.DateUtils;
|
import com.chaozhanggui.system.cashierservice.util.DateUtils;
|
||||||
|
import com.chaozhanggui.system.cashierservice.util.HttpClientUtil;
|
||||||
import com.chaozhanggui.system.cashierservice.util.RedisUtil;
|
import com.chaozhanggui.system.cashierservice.util.RedisUtil;
|
||||||
import com.chaozhanggui.system.cashierservice.util.TokenUtil;
|
import com.chaozhanggui.system.cashierservice.util.TokenUtil;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
@@ -19,6 +23,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@@ -81,15 +86,28 @@ public class OrderService {
|
|||||||
if (ObjectUtil.isEmpty(product) || !"1".equals(product.getStatus().toString())) {
|
if (ObjectUtil.isEmpty(product) || !"1".equals(product.getStatus().toString())) {
|
||||||
return Result.fail(CodeEnum.PRODUCTINFOERROR);
|
return Result.fail(CodeEnum.PRODUCTINFOERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
TbProductSkuWithBLOBs skuWithBLOBs;
|
TbProductSkuWithBLOBs skuWithBLOBs;
|
||||||
if ("1".equals(product.getTypeEnum())) {
|
if ("1".equals(product.getTypeEnum())) {
|
||||||
skuWithBLOBs = tbProductSkuMapper.selectByProduct(Integer.valueOf(productId));
|
skuWithBLOBs = tbProductSkuMapper.selectByProduct(Integer.valueOf(productId));
|
||||||
} else {
|
} else {
|
||||||
skuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(skuId));
|
skuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(skuId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (ObjectUtil.isEmpty(skuWithBLOBs)) {
|
if (ObjectUtil.isEmpty(skuWithBLOBs)) {
|
||||||
return Result.fail(CodeEnum.PRODUCTSKUERROR);
|
return Result.fail(CodeEnum.PRODUCTSKUERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if("1".equals(product.getIsStock().toString())){
|
||||||
|
if(product.getId().intValue()==Integer.valueOf(skuWithBLOBs.getProductId()).intValue()){
|
||||||
|
if(skuWithBLOBs.getStockNumber()-number<0){
|
||||||
|
return Result.fail(CodeEnum.STOCKERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (StringUtils.isEmpty(masterId)) {
|
if (StringUtils.isEmpty(masterId)) {
|
||||||
boolean flag = redisUtil.exists("SHOP:CODE:" + clientType + ":" + shopId);
|
boolean flag = redisUtil.exists("SHOP:CODE:" + clientType + ":" + shopId);
|
||||||
if (flag) {
|
if (flag) {
|
||||||
@@ -182,6 +200,11 @@ public class OrderService {
|
|||||||
cashierCartMapper.updateStatus(cashierCart.getId(), "close");
|
cashierCartMapper.updateStatus(cashierCart.getId(), "close");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
skuWithBLOBs.setStockNumber(skuWithBLOBs.getStockNumber()-number);
|
||||||
|
skuWithBLOBs.setUpdatedAt(System.currentTimeMillis());
|
||||||
|
tbProductSkuMapper.updateByPrimaryKey(skuWithBLOBs);
|
||||||
|
|
||||||
redisUtil.addSet("SHOP:CODE:SET" + clientType + ":" + shopId + ":" + DateUtils.getDay(),masterId.substring(1,masterId.length()));
|
redisUtil.addSet("SHOP:CODE:SET" + clientType + ":" + shopId + ":" + DateUtils.getDay(),masterId.substring(1,masterId.length()));
|
||||||
return Result.success(CodeEnum.SUCCESS, masterId);
|
return Result.success(CodeEnum.SUCCESS, masterId);
|
||||||
}
|
}
|
||||||
@@ -249,7 +272,26 @@ public class OrderService {
|
|||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Result delCart(String masterId, Integer cartId) {
|
public Result delCart(String masterId, Integer cartId) {
|
||||||
|
|
||||||
|
|
||||||
|
TbCashierCart cashierCart=cashierCartMapper.selectByPrimaryKey(cartId);
|
||||||
|
if(ObjectUtil.isEmpty(cashierCart)){
|
||||||
|
return Result.fail(CodeEnum.CARTEXIST);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TbProductSkuWithBLOBs skuWithBLOBs= tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getSkuId()));
|
||||||
|
if(ObjectUtil.isEmpty(skuWithBLOBs)){
|
||||||
|
return Result.fail(CodeEnum.PRODUCTSKUERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
cashierCartMapper.deleteByCartId(masterId, cartId);
|
cashierCartMapper.deleteByCartId(masterId, cartId);
|
||||||
|
|
||||||
|
skuWithBLOBs.setStockNumber(skuWithBLOBs.getStockNumber()+cashierCart.getTotalNumber());
|
||||||
|
skuWithBLOBs.setUpdatedAt(System.currentTimeMillis());
|
||||||
|
tbProductSkuMapper.updateByPrimaryKey(skuWithBLOBs);
|
||||||
|
|
||||||
return Result.success(CodeEnum.SUCCESS);
|
return Result.success(CodeEnum.SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -603,10 +645,13 @@ public class OrderService {
|
|||||||
String day = DateUtils.getDay();
|
String day = DateUtils.getDay();
|
||||||
List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(cartVo.getMasterId(), Integer.valueOf(cartVo.getShopId()), day, "create", cartVo.getUuid());
|
List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(cartVo.getMasterId(), Integer.valueOf(cartVo.getShopId()), day, "create", cartVo.getUuid());
|
||||||
int orderId = 0;
|
int orderId = 0;
|
||||||
|
List<ProductSkuPo> productSkuPos=new ArrayList<>();
|
||||||
for (TbCashierCart cashierCart : list) {
|
for (TbCashierCart cashierCart : list) {
|
||||||
if (StringUtils.isNotEmpty(cashierCart.getOrderId())) {
|
if (StringUtils.isNotEmpty(cashierCart.getOrderId())) {
|
||||||
orderId = Integer.valueOf(cashierCart.getOrderId());
|
orderId = Integer.valueOf(cashierCart.getOrderId());
|
||||||
}
|
}
|
||||||
|
ProductSkuPo skuPo=new ProductSkuPo(Integer.valueOf(cashierCart.getSkuId()),cashierCart.getTotalNumber());
|
||||||
|
productSkuPos.add(skuPo);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (orderId > 0) {
|
if (orderId > 0) {
|
||||||
@@ -614,10 +659,13 @@ public class OrderService {
|
|||||||
if (Objects.nonNull(orderInfo) && !orderInfo.getStatus().equals("pending")){
|
if (Objects.nonNull(orderInfo) && !orderInfo.getStatus().equals("pending")){
|
||||||
tbOrderInfoMapper.updateStatusById(orderId, "cancelled");
|
tbOrderInfoMapper.updateStatusById(orderId, "cancelled");
|
||||||
orderDetailMapper.updateStatusByOrderId(orderId, "cancelled");
|
orderDetailMapper.updateStatusByOrderId(orderId, "cancelled");
|
||||||
cashierCartMapper.deleteBymasterId(cartVo.getMasterId(), Integer.valueOf(cartVo.getShopId()), day, "create", cartVo.getUuid());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cashierCartMapper.deleteBymasterId(cartVo.getMasterId(), Integer.valueOf(cartVo.getShopId()), day, "create", cartVo.getUuid());
|
||||||
|
|
||||||
|
tbProductSkuMapper.batchStockNum(productSkuPos);
|
||||||
|
|
||||||
return Result.success(CodeEnum.SUCCESS);
|
return Result.success(CodeEnum.SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -787,4 +835,126 @@ public class OrderService {
|
|||||||
}
|
}
|
||||||
return Result.success(CodeEnum.SUCCESS, orderInfo);
|
return Result.success(CodeEnum.SUCCESS, orderInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
TbUserInfoMapper tbUserInfoMapper;
|
||||||
|
|
||||||
|
|
||||||
|
@Value("${wx.appId}")
|
||||||
|
private String appId;
|
||||||
|
|
||||||
|
|
||||||
|
@Value("${wx.secrete}")
|
||||||
|
private String secrete;
|
||||||
|
|
||||||
|
|
||||||
|
public Result sendMassage(String orderId){
|
||||||
|
if(ObjectUtil.isEmpty(orderId)){
|
||||||
|
return Result.fail(CodeEnum.ERRMASTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TbOrderInfo orderInfo=tbOrderInfoMapper.selectByPrimaryKey(Integer.valueOf(orderId));
|
||||||
|
if(ObjectUtil.isEmpty(orderInfo)){
|
||||||
|
return Result.fail(CodeEnum.ORDERNOEXIST);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!orderInfo.getOrderType().startsWith("miniapp")){
|
||||||
|
return Result.fail(CodeEnum.ISNOTWXORDER);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TbShopInfo shopInfo= tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getShopId()));
|
||||||
|
|
||||||
|
if(ObjectUtil.isEmpty(shopInfo)){
|
||||||
|
return Result.fail(CodeEnum.SHOPINFONOEXIST);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TbUserInfo userInfo= tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getUserId()));
|
||||||
|
if(ObjectUtil.isEmpty(userInfo)||ObjectUtil.isEmpty(userInfo.getMiniAppOpenId())){
|
||||||
|
return Result.fail(CodeEnum.USERNOEXIST);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
JSONObject object= getAccessToken();
|
||||||
|
String accessToken=object.get("access_token")+"";
|
||||||
|
|
||||||
|
JSONObject object1=new JSONObject();
|
||||||
|
|
||||||
|
object1.put("template_id","z0fUG7-jhSfYCrw6poOvSRzh4_hgnPkm_5C7E5s5bCQ");
|
||||||
|
object1.put("touser",userInfo.getMiniAppOpenId());
|
||||||
|
|
||||||
|
|
||||||
|
JSONObject data=new JSONObject();
|
||||||
|
|
||||||
|
JSONObject tabname=new JSONObject();
|
||||||
|
tabname.put("value",orderInfo.getTableName());
|
||||||
|
|
||||||
|
|
||||||
|
JSONObject thing21=new JSONObject();
|
||||||
|
thing21.put("value",shopInfo.getShopName());
|
||||||
|
|
||||||
|
|
||||||
|
JSONObject thing8=new JSONObject();
|
||||||
|
thing8.put("value","你的餐品已出餐,请及时取餐。");
|
||||||
|
|
||||||
|
data.put("character_string1",tabname);
|
||||||
|
data.put("thing21",thing21);
|
||||||
|
data.put("thing8",thing8);
|
||||||
|
|
||||||
|
object1.put("data",data);
|
||||||
|
|
||||||
|
object1.put("miniprogram_state","trial");
|
||||||
|
object1.put("lang","zh_CN");
|
||||||
|
|
||||||
|
String response= HttpRequest.post("https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=".concat(accessToken)).body(object1.toString()).execute().body();
|
||||||
|
log.info("返回结果:{}",response);
|
||||||
|
JSONObject resObj=JSONObject.parseObject(response);
|
||||||
|
if(ObjectUtil.isNotEmpty(resObj)&&ObjectUtil.isNotNull(resObj)&&"0".equals(resObj.get("errcode")+"")){
|
||||||
|
return Result.success(CodeEnum.SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return Result.fail(linkedHashMap.containsKey(resObj.get("errcode")+"")?linkedHashMap.get(resObj.get("errcode")+""):"未知错误");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static LinkedHashMap<String,String> linkedHashMap=new LinkedHashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
|
||||||
|
linkedHashMap.put("40001","获取 access_token 时 AppSecret 错误,或者 access_token 无效。请开发者认真比对 AppSecret 的正确性,或查看是否正在为恰当的公众号调用接口");
|
||||||
|
linkedHashMap.put("40003","不合法的 OpenID ,请开发者确认 OpenID (该用户)是否已关注公众号,或是否是其他公众号的 OpenID");
|
||||||
|
linkedHashMap.put("40014","不合法的 access_token ,请开发者认真比对 access_token 的有效性(如是否过期),或查看是否正在为恰当的公众号调用接口");
|
||||||
|
linkedHashMap.put("40037","不合法的 template_id");
|
||||||
|
linkedHashMap.put("43101","用户未订阅消息");
|
||||||
|
linkedHashMap.put("43107","订阅消息能力封禁");
|
||||||
|
linkedHashMap.put("43108","并发下发消息给同一个粉丝");
|
||||||
|
linkedHashMap.put("45168","命中敏感词");
|
||||||
|
linkedHashMap.put("47003","参数错误");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
JSONObject getAccessToken(){
|
||||||
|
String requestUrl = "https://api.weixin.qq.com/cgi-bin/token";
|
||||||
|
Map<String, String> requestUrlParam = new HashMap<>();
|
||||||
|
//小程序appId
|
||||||
|
requestUrlParam.put("appid", appId);
|
||||||
|
//小程序secret
|
||||||
|
requestUrlParam.put("secret", secrete);
|
||||||
|
//默认参数
|
||||||
|
requestUrlParam.put("grant_type", "client_credential");
|
||||||
|
JSONObject jsonObject = JSON.parseObject(HttpClientUtil.doGet(requestUrl,requestUrlParam));
|
||||||
|
return jsonObject;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -430,9 +430,6 @@ public class PayService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(Integer.valueOf(orderId));
|
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(Integer.valueOf(orderId));
|
||||||
if (ObjectUtil.isEmpty(orderInfo)) {
|
if (ObjectUtil.isEmpty(orderInfo)) {
|
||||||
return Result.fail(CodeEnum.ORDERNOEXIST);
|
return Result.fail(CodeEnum.ORDERNOEXIST);
|
||||||
@@ -494,6 +491,7 @@ public class PayService {
|
|||||||
|
|
||||||
|
|
||||||
orderInfo.setPayAmount(orderInfo.getOrderAmount());
|
orderInfo.setPayAmount(orderInfo.getOrderAmount());
|
||||||
|
orderInfo.setUserId(user.getUserId());
|
||||||
orderInfo.setMemberId(memberId);
|
orderInfo.setMemberId(memberId);
|
||||||
orderInfo.setPayType("deposit");
|
orderInfo.setPayType("deposit");
|
||||||
orderInfo.setStatus("closed");
|
orderInfo.setStatus("closed");
|
||||||
@@ -848,6 +846,10 @@ public class PayService {
|
|||||||
if(ObjectUtil.isNull(user)||ObjectUtil.isEmpty(user)){
|
if(ObjectUtil.isNull(user)||ObjectUtil.isEmpty(user)){
|
||||||
return Result.fail(ACCOUNTEIXST);
|
return Result.fail(ACCOUNTEIXST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
newOrderInfo.setMemberId(orderInfo.getMemberId());
|
||||||
|
newOrderInfo.setUserId(orderInfo.getUserId());
|
||||||
|
|
||||||
user.setAmount(user.getAmount().add( newOrderInfo.getPayAmount().setScale(2, RoundingMode.DOWN)));
|
user.setAmount(user.getAmount().add( newOrderInfo.getPayAmount().setScale(2, RoundingMode.DOWN)));
|
||||||
user.setConsumeAmount(user.getConsumeAmount().subtract( newOrderInfo.getPayAmount().setScale(2, RoundingMode.DOWN)));
|
user.setConsumeAmount(user.getConsumeAmount().subtract( newOrderInfo.getPayAmount().setScale(2, RoundingMode.DOWN)));
|
||||||
user.setUpdatedAt(System.currentTimeMillis());
|
user.setUpdatedAt(System.currentTimeMillis());
|
||||||
|
|||||||
@@ -67,6 +67,45 @@ public enum CodeEnum {
|
|||||||
|
|
||||||
|
|
||||||
ERRORQR("100026",false,"错误的码信息","fail"),
|
ERRORQR("100026",false,"错误的码信息","fail"),
|
||||||
|
|
||||||
|
|
||||||
|
ERRMASTER("100027",false,"错误的取餐码","fail"),
|
||||||
|
|
||||||
|
ISNOTWXORDER("100028",false,"不是小程序订单","fail"),
|
||||||
|
|
||||||
|
|
||||||
|
USERNOEXIST("100029",false,"用户信息不存在","fail"),
|
||||||
|
|
||||||
|
|
||||||
|
STOCKERROR("100030",false,"库存不足","fail"),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -91,7 +130,6 @@ public enum CodeEnum {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
private String code;
|
private String code;
|
||||||
|
|||||||
@@ -355,4 +355,13 @@
|
|||||||
resultType="com.chaozhanggui.system.cashierservice.entity.TbProductSkuWithBLOBs">
|
resultType="com.chaozhanggui.system.cashierservice.entity.TbProductSkuWithBLOBs">
|
||||||
select * from tb_product_sku where product_id = #{productId}
|
select * from tb_product_sku where product_id = #{productId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<update id="batchStockNum">
|
||||||
|
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
|
||||||
|
update tb_product_sku
|
||||||
|
set stock_number= stock_number+ #{item.number},
|
||||||
|
where id = #{item.skuId}
|
||||||
|
</foreach>
|
||||||
|
|
||||||
|
</update>
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user